Launch RCP application from main()
Asked Answered
L

3

5

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?

Leventis answered 9/3, 2012 at 15:53 Comment(0)
P
5

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!

Platinic answered 9/3, 2012 at 21:9 Comment(0)
C
2

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.

Cousins answered 12/3, 2012 at 7:46 Comment(0)
I
2

Simply create a fork of bundle org.eclipse.equinox.launcher it has a class Main with the static main function (aka the entry point) which delegates to the run-function. You can subclass it an overwrite the run-function and do what you want to do.

Interregnum answered 22/4, 2013 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.