Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to specify the path of a file bundled in the package
how to specify the path of a file bundled in the package [message #649334] Tue, 18 January 2011 19:11 Go to next message
fran81 Missing name is currently offline fran81 Missing name
Messages: 27
Registered: November 2010
Junior Member
I am trying to load an external dll file into my java program, however if I give the absolute path (for example "lib"), eclipse will look for this file under the eclipse installation directory rather than in the package itself.

I'd like to have something like
Activator.getImageDescriptor("icons/myimage.gif")...

but how does it work for general files?

Thanks,
Francesca
Re: how to specify the path of a file bundled in the package [message #649336 is a reply to message #649334] Tue, 18 January 2011 19:22 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you have a file in your bundle, you can use Bundle.getEntry(*) to get
a URL to that file and FileLocator API to make sure it points to a file
on your filesystem.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: how to specify the path of a file bundled in the package [message #649343 is a reply to message #649336] Tue, 18 January 2011 20:05 Go to previous messageGo to next message
fran81 Missing name is currently offline fran81 Missing name
Messages: 27
Registered: November 2010
Junior Member
Thanks Paul.

I am not sure if I am doing the right way...

I have written

Bundle bundle = org.eclipse.core.runtime.Platform.getBundle"idofmyplugin");

String path = bundle.getEntry("lib").getPath();

The string path is returned as C:\lib

However there's no lib under C:
The folder lib is in the workspace at the same level as other folders like "icons" or "src"

Any clue?

Thank you very much for the quick reply!!

Francesca
Re: how to specify the path of a file bundled in the package [message #649495 is a reply to message #649343] Wed, 19 January 2011 13:18 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 01/18/2011 03:05 PM, fran81 wrote:
> Thanks Paul.
>
> I am not sure if I am doing the right way...
>
> I have written
>
> Bundle bundle = org.eclipse.core.runtime.Platform.getBundle"idofmyplugin");
>

Don't use getPath(*) in the URL, instead use FileLocator to turn it into
an absolute file system path

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: how to specify the path of a file bundled in the package [message #649606 is a reply to message #649495] Wed, 19 January 2011 21:32 Go to previous message
fran81 Missing name is currently offline fran81 Missing name
Messages: 27
Registered: November 2010
Junior Member
Thanks Paul, it's working now.

I have

Bundle bundle = org.eclipse.core.runtime.Platform.getBundle"idofmyplugin");
try {
String path = FileLocatior.resolve(bundle.getEntry("lib")).getPath();
} catch (IOException e) {

}
Previous Topic:Remove Web Browser View
Next Topic:Workaround for Bug 139064 on Linux (JNI: UnsatisfiedLinkError)?
Goto Forum:
  


Current Time: Thu Sep 18 17:58:04 GMT 2014

Powered by FUDForum. Page generated in 0.04067 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software