Suzan Cioc
Suzan Cioc

Reputation: 30097

Where is application-scope location of resources in Eclipse RCP?

I am wrapping some 3rd party application into Eclipse plugin.

This application uses some data files in "current" directory, i.e. directory where application ran from.

Initially I put all of theses files at first level in Eclipse plugin project and can access these files via

bundle.getEntry("./conf/conf.xml")

unfortunately, this code creates strange URLs like

bundleentry://88.fwk1692538903/./conf/conf.xml

Why is it so? Is it possible to put all application-scoped files into some global location and refer it from a plugin?

Upvotes: 0

Views: 142

Answers (1)

greg-449
greg-449

Reputation: 111142

Use org.eclipse.core.runtime.FileLocator to convert the bundleentry URL to a normal file URL:

URL bundleURL = bundle.getEntry("...");

URL fileURL = FileLocator.toFileURL(bundleURL);

Note: If the plugin is in a jar rather than expanded during install the URL returned may reference a temporary location in the metadata where the plugin has been expanded.

Upvotes: 2

Related Questions