Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Create launch configurations programmatically(Create launch configurations programmatically)
Create launch configurations programmatically [message #641434] Thu, 25 November 2010 13:15 Go to next message
loubas is currently offline loubasFriend
Messages: 4
Registered: July 2010
Junior Member
Hi,


Do you know where I can find a concrete example of Java code that creates a launch configuration file from scratch and then run it?

thank you very much


Re: Create launch configurations programmatically [message #641990 is a reply to message #641434] Mon, 29 November 2010 13:31 Go to previous messageGo to next message
loubas is currently offline loubasFriend
Messages: 4
Registered: July 2010
Junior Member
I managed to write this code

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type =manager.getLaunchConfigurationType("org.eclipse.pde.ui.EquinoxLauncher ");


ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type);
for (int i = 0; i < lcs.length; ++i) {
if (lcs[i].getName().equals("Test service")) {
ILaunchConfigurationWorkingCopy t=lcs[i].getWorkingCopy();
ILaunchConfiguration config = t.doSave();
if (config != null)
config.launch(ILaunchManager.RUN_MODE, null);
}
}

for running osgi but I get the following error:



java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:74)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


while my config.ini file contains the following:
#Configuration File
#Mon Nov 29 15:29:19 EET 2010
osgi.bundles.defaultStartLevel=4
osgi.install.area=file\:D\:\\eclipse
osgi.framework=file\:D\:/eclipse/plugins/org.eclipse.osgi_3. 6.1.R36x_v20100806.jar
osgi.configuration.cascaded=false


I should mention that when I run the configuration through eclipse gui everything works perfectly.

Thank you in advance
Re: Create launch configurations programmatically [message #667248 is a reply to message #641990] Wed, 27 April 2011 15:35 Go to previous message
keller_jens is currently offline keller_jensFriend
Messages: 21
Registered: March 2010
Location: Germany
Junior Member
Hi Loubas,
if you have not already found a solution, maybe this one could help:
http://www.eclipse.org/articles/Article-Java-launch/launchin g-java.html

I guess you have to pass your configuration to
DebugUITools.launch(configuration, ILaunchManager.RUN_MODE);
rather than directly calling the configuration.launch() method.

Regards, Jens
Previous Topic:how can i revert back to original perspective ??
Next Topic:Source not Found
Goto Forum:
  


Current Time: Fri Apr 19 22:21:10 GMT 2024

Powered by FUDForum. Page generated in 0.02977 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top