I'm trying to make an Eclipse launch configuration that I can launch programmatically, kind of building a custom debugger if you like.
我正在尝试做一个Eclipse启动配置,我可以用编程的方式启动它,可以构建一个自定义调试器。
I've already got an org.eclipse.debug.core.launchConfigurationTypes
extension, as well as .core.launchDelegates
, .ui.launchConfigurationTabGroups
and .core.sourcePathComputers
extensions.
我已经获得了一个org.eclipse.debug.core.launchConfigurationTypes扩展,以及.core。launchDelegates。ui。launchConfigurationTabGroups .core。sourcePathComputers扩展。
I've got a button that executes the following code:
我有一个执行以下代码的按钮:
ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType lct = mgr.getLaunchConfigurationType(IOpcodeConstants.LAUNCH_CFG_TYPE);
ILaunchConfiguration[] lcs = mgr.getLaunchConfigurations(lct);
for (int i = 0; i < lcs.length; ++i) {
if (lcs[i].getName().equals("Opcode")) {
lcs[i].delete();
break;
}
}
ILaunchConfigurationWorkingCopy wc = lct.newInstance(null, "Opcode");
Set<String> modes = new HashSet<String>();
modes.add(ILaunchManager.DEBUG_MODE);
wc.setModes(modes);
wc.setPreferredLaunchDelegate(modes, "nz.net.fantail.studio.OpcodeLaunchDelegate");
ILaunchConfiguration lc = wc.doSave();
lc.launch(ILaunchManager.DEBUG_MODE, null);
My launch delegate has the following code:
我的发射委托有以下代码:
@Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
ManagementClient client = new ManagementClient("localhost", 6961);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
IDebugTarget target = new OpcodeDebugTarget(launch, client);
launch.addDebugTarget(target);
}
}
Everything works perfectly fine until get tries to load the ManagementClient class and throws a NoSuchClassDefException. I suspect this is because it launches in a separate environment from the actual application and as such doesn't have the .jar with the class in its classpath.
在get尝试加载ManagementClient类并抛出NoSuchClassDefException之前,一切都运行良好。我怀疑这是因为它在一个单独的环境中从实际的应用程序中启动,因为它没有在类路径中包含类的.jar。
Does anyone know how to get around this issue? Cheers!
有人知道怎么解决这个问题吗?干杯!
2 个解决方案
#1
1
What class is it not finding, the ManagementClient or something else? Maybe in your launch configuration you need to set the target classpath yourself.
它找不到什么类,管理客户端还是别的什么?也许在启动配置中,您需要自己设置目标类路径。
// customize the classpath
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classPathList);
Here are some other settings that may be useful:
以下是一些其他可能有用的设置:
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
projectName);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
targetMainClass);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
programArgs);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, jvmArgs);
#2
0
Why do you need the button that launches the configuration? If you extend the extension points you mentioned your launch configuration should appear in the debug menu of eclipse ... no need for a seperate button!?
为什么需要启动配置的按钮?如果扩展了您提到的扩展点,那么您的启动配置应该出现在eclipse的debug菜单中……不需要分开的按钮!?
Appart from this I would look after the dependencies of the plugin that contains "ManagementClient". The "NoSuchClassDefException" most often is a result of wrong dependency definitions (maybe the order of the dependencies is wrong [core plugins before ui plugins] ... or your class isn't in an plugin altogether?).
为此,我将关注包含“ManagementClient”的插件的依赖关系。“NoSuchClassDefException”通常是错误依赖定义的结果(可能依赖项的顺序是错误的[ui插件之前的核心插件]……或者你的类并不是一个插件)。
#1
1
What class is it not finding, the ManagementClient or something else? Maybe in your launch configuration you need to set the target classpath yourself.
它找不到什么类,管理客户端还是别的什么?也许在启动配置中,您需要自己设置目标类路径。
// customize the classpath
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classPathList);
Here are some other settings that may be useful:
以下是一些其他可能有用的设置:
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
projectName);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
targetMainClass);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
programArgs);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, jvmArgs);
#2
0
Why do you need the button that launches the configuration? If you extend the extension points you mentioned your launch configuration should appear in the debug menu of eclipse ... no need for a seperate button!?
为什么需要启动配置的按钮?如果扩展了您提到的扩展点,那么您的启动配置应该出现在eclipse的debug菜单中……不需要分开的按钮!?
Appart from this I would look after the dependencies of the plugin that contains "ManagementClient". The "NoSuchClassDefException" most often is a result of wrong dependency definitions (maybe the order of the dependencies is wrong [core plugins before ui plugins] ... or your class isn't in an plugin altogether?).
为此,我将关注包含“ManagementClient”的插件的依赖关系。“NoSuchClassDefException”通常是错误依赖定义的结果(可能依赖项的顺序是错误的[ui插件之前的核心插件]……或者你的类并不是一个插件)。