I am writing an Eclipse product, composed of plugins.
In one of my plugins, I need to get the absolute path to the directory where Eclipse is installed.
(i.e. /Applications/Eclipse
on Mac or C:\Program Files\Eclipse
on Win).
Can't find an API for this. Ideas?
For windows, it's in the same directory as eclipse.exe file, as shown in below image. You can reach this location by first right clicking on Eclipse app and click on “Show Package Contents” and then in the next window navigate to Contents/Eclipse directory, as shown in below images.
You just have to move the eclipse folder to the new location. There's no need to change anything in the PATH variable because this thing is only needed by eclipse itself to locate the java environment.
codejammer suggests:
The following gives you the installed location
Platform.getInstallLocation().getURL()
See the org.eclipse.core.runtime.Platform
API
/**
* Returns the location of the base installation for the running platform
* <code>null</code> is returned if the platform is running without a configuration location.
* <p>
* This method is equivalent to acquiring the <code>org.eclipse.osgi.service.datalocation.Location</code>
* service with the property "type" equal to {@link Location#INSTALL_FILTER}.
*</p>
* @return the location of the platform's installation area or <code>null</code> if none
* @since 3.0
* @see Location#INSTALL_FILTER
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With