Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Launching a product from within Java(Possible?)
Launching a product from within Java [message #544004] Thu, 01 July 2010 06:21 Go to next message
Chris is currently offline Chris
Messages: 3
Registered: July 2010
Junior Member
Hello there,

I'm looking to find out if possible whether there is a way to launch an Equinox OSGI prodct from within Java.

Currently we launch via JNLP or via an Eclipse.exe however we have a new requirement to now launch from within an already running java application.

Within our JNLP we have many plugin's and a product under the resources. Then of course we have the start options for some of the plugins as well as instance areas and other properties.

		String[] equinoxArgs = { "-console", "1234", "-noExit" };
		
		BundleContext context = EclipseStarter.startup(equinoxArgs, null);

		Bundle bundle = context.installBundle("http://www.eclipsezone.com/files/jsig/bundles/HelloWorld.jar");
		bundle.start();


Is what I've found so far with a little google action, but are my plugin's bundles? Is there any more documentation on where I set the properties for products and other properties?

It's worth mentioning that all the plugins will be local on disk somewhere.

Thanks for any help or pointers!!

Chris

[Updated on: Thu, 01 July 2010 06:40]

Report message to a moderator

Re: Launching a product from within Java [message #546000 is a reply to message #544004] Fri, 09 July 2010 16:29 Go to previous messageGo to next message
ib  is currently offline ib
Messages: 2
Registered: July 2010
Junior Member
Hi Chris,

If it's an OSGi product, you can launch your product inside a regular POJO. Here is an example:

public class MyTestClass
{
    public void myMethod(Object interestingObj)
    {
        String[] arguments = {"-consolelog",  "-noExit",  "-product", "myeclipse.product", "-name",  "My Product", "-install",  "\\MyProductDir", "-configuration",   "\\MyProductDir\\configuration"};
    	
    	
        Main.main(arguments);
    }
}


Hope this helps.
Re: Launching a product from within Java [message #714730 is a reply to message #546000] Thu, 11 August 2011 07:53 Go to previous message
Chris is currently offline Chris
Messages: 3
Registered: July 2010
Junior Member
import org.eclipse.core.runtime.adaptor.EclipseStarter;

public class LaunchOsgi 
{
	public static void main(String args[]) throws Exception 
	{
		if(args.length == 0)
		{
			System.err.println("Usage: configuration-directory");
			System.exit(1);
		}

		try
		{ 
			Map<String, String> initProps = new HashMap<String, String> ();
			initProps.put("osgi.configuration.area", args[0]);

			EclipseStarter.setInitialProperties(initProps);   
			EclipseStarter.debug = true;

			EclipseStarter.startup(new String[]{}, null);
			EclipseStarter.run(new String[]{});
		}
		catch(Throwable t)
		{
			t.printStackTrace();
		}
		finally
		{
			EclipseStarter.shutdown();
		}
	}
}


I know this is an old thread but it might help someone else with a similar question.

Here is the solution we used in the end, you only need to specify the configuration path.
Previous Topic:loading higher version bundle when multiple versions are present
Next Topic:RCP App remote debugging another
Goto Forum:
  


Current Time: Wed May 22 23:42:04 EDT 2013

Powered by FUDForum. Page generated in 0.01575 seconds