3

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

Snehal
  • 7,266
  • 2
  • 32
  • 42

2 Answers2

6

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,262,500
  • 529
  • 4,410
  • 5,250
5

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
  • 19,853
  • 5
  • 45
  • 59
  • 8 Years later, but there is actually an use-case. For example if you are implementing a SecurityManager and you want to automatically allow read requests to the Eclipse directory. Else there are lot of pollution in the security requests, as the Eclipse classloaders try to read the plugin jars and other files often. – Sipka Apr 16 '17 at 20:18