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?
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!
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.
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.
© 2022 - 2024 — McMap. All rights reserved.