The easiest way is to use
org.eclipse.core.runtime.Platform
class and its static
getInstallLocation
method.
Location installLocation = Platform.getInstallLocation();
A Location interface is defined in OSGi specification and basically represents an java.net.URL object. Additionally it allows creating nested locations and mechanism for locking locations.
The default and the only one shipped implementation is BasicLocation, but it is internal class and just pure implementation (no other fancy features ;)
To obtain path as a String user the following code:
String absolutePath = Platform.getInstallLocation().getURL().getFile();
Alternatively you can read the content
InputStream is = Platform.getInstallLocation().getURL().getContent();
Brak komentarzy:
Prześlij komentarz