Eclipse:如何以编程方式执行启动配置?

时间:2012-04-11 10:32:27

标签: java eclipse

我的Eclipse项目中有各种启动配置文件。有没有办法以编程方式执行任意启动配置?

1 个答案:

答案 0 :(得分:2)

       ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

       ILaunchConfigurationType type =     manager.getLaunchConfigurationType("org.eclipse.cdt.launch.applicationLaunchType");
       ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type);

            for (ILaunchConfiguration iLaunchConfiguration : lcs) {
                if (iLaunchConfiguration.getName().equals("Test PThread")) {
                    ILaunchConfigurationWorkingCopy t = iLaunchConfiguration.getWorkingCopy();
                    ILaunchConfiguration config = t.doSave();
                    if (config != null) {
                        // config.launch(ILaunchManager.RUN_MODE, null);
                        DebugUITools.launch(config, ILaunchManager.DEBUG_MODE);
                    }
                }
            }