Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch RCP application from main()

I know it's possible to export my rcp application, create a .exe file and run it with the command "Runtime.getRuntime().exec()" but, I'd like to launch my rcp application from the main method of a java class without creating and call the exe. is it possible?

like image 460
Silvio Avatar asked Mar 09 '12 15:03

Silvio


2 Answers

I am not sure it is really helpful to you, it depends on why you need to start another IApplication, but anyway...

I would read the wiki page about Equinox Application Model Demo which demonstrates how the OSGi Application Admin service can be used to control Application. You can get the code from the CVS as described there. You can also check the code in the org.eclipse.equinox.internal.app.AppCommands class, namely in the _startApp() method, which also starts an already defined application, and is the implementation of the "startApp" command in the OSGi console.

Note that you might need to adjust the way you start the Eclipse instance from which you want to start the other application (e.g. the eclipse.application.registerDescriptors runtime option see the help page).

Hope this helps!

like image 119
Urbi Avatar answered Oct 08 '22 23:10

Urbi


Assuming you already have OSGi running, the answer from @Urbi is right. If you also need to start OSGi, then be careful that you do this from your own main thread - i.e. the initial thread of your application - as SWT otherwise will not work properly on all platforms.

Have a look at org.eclipse.core.runtime.adaptor.EclipseStarter for the way to start OSGi and your application.

like image 43
Tonny Madsen Avatar answered Oct 08 '22 23:10

Tonny Madsen