Search code examples
javaeclipsercp

Programmatically reference folder or file from Eclipse product directory


I'm creating an Eclipse RCP product that will have a /bin directory in the top level folder that will contain some file. What's the best approach for programmatically getting to the /bin location?

Product directory:

Product directory


Solution

  • In a plugin use Platform.getInstallLocation to get the installation directory location:

    URL installURL = Platform.getInstallLocation().getURL();
    
    String path = URIUtil.toURI(installURL).toASCIIString();
    

    Both Platform and URIUtil are in the org.eclipse.core.runtime package / plugin.