views:

453

answers:

2

Hi,

I opened eclipse 3.3.2. Now i need to get the current eclispe installation path. Is

there any eclipse API to get the eclipse installation path? Please help in this regard.

Thanks in Advance..

Snehal

+1  A: 

Since eclipse3.4 and the p2 mechanism, you coud use org.eclipse.osgi.service.datalocation.Location, which represents a URL.

That interface includes **ECLIPSE_HOME_FILTER**, a constant which defines the filter string for acquiring the service which specifies the eclipse home location (i.e. "eclipse.home.location".)

But in eclipse3.3, just query the property value "eclipse.home.location", as in:

System.getProperty("eclipse.home.location");
VonC
+1  A: 

It is a bit questionable as to why you would need the installation path. Your code (a plugin) should not depend on anything in the installation directory. If you are thinking of writing to the installation directory. Don't! You won't be able to do that in a shared install and it's a very bad idea anyway.

If you for example need to access a file inside your plugin you would simply use code like this:

Activator.getDefault().getBundle().getEntry(fileName);

To get the location of the users workspace

Platform.getInstanceLocation().getURL().getPath();
lothar