Access relative path from eclipse-plugin

Does anyone know how to get uri file from a self-made Eclipse plug-in?

Absolute paths will not be a problem:

URI.createFileURI("C:/Users/hp/workspace(dke)/SMartGen/StarSchema.profile.uml");

But how do I access local resources relatively?

URI.createFileURI("jar:file:/%ECLIPSE_HOME%/plugins/SMartGen.jar!StarSchema.profile.uml");

doesn't work that way ....

Happy for every answer.

lg martin

+3
source share
2 answers

Use FileLocator .

Example:

URL iconUrl = FileLocator.find(Platform.getBundle("myBundle"), new Path("icons/someIcon.png"), null);

This will get the URL of the file "someIcon.png", which is located in the "icons" folder in the "myBundle" package.

+3
source

, org.osgi.framework.Bundle.getEntry(String). java.net.URL, InputStream . , , , jar .

Bundle bundle = FrameworkUtil.getBundle(MyClass.class);
URL url = bundle.getEntry("StarSchema.profile.uml");

URL- toURI() .

0

All Articles