Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

java - Eclipse: How can I execute a launch configuration programmatically?

I have various launch configuration files in my Eclipse project. Is there any way how I can execute an arbitrary launch configuration programmatically?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
       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);
                    }
                }
            }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...