Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to access/read files bundled in your plug-ins as jar files?
How to access/read files bundled in your plug-ins as jar files? [message #502070] Sat, 05 December 2009 03:33 Go to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Hi,

I have a plug-in that has some data files. How would my plug-in access
those data files once deployed as jars? (this is somewhat like a
documentation plug-in that has HTML pages, etc.)

Any tips/sample code is appreciated.

Thanks
Re: How to access/read files bundled in your plug-ins as jar files? [message #502080 is a reply to message #502070] Sat, 05 December 2009 09:34 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
You can do something like this:

Bundle bundle = Platform.getBundle("your.plugin.id"); //$NON-NLS-1$
URL url = bundle.getResource("nameoffile");



Re: How to access/read files bundled in your plug-ins as jar files? [message #502408 is a reply to message #502080] Tue, 08 December 2009 02:45 Go to previous messageGo to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Francis Upton wrote:
> You can do something like this:
>
> Bundle bundle = Platform.getBundle("your.plugin.id"); //$NON-NLS-1$
> URL url = bundle.getResource("nameoffile");
>
>

Same thing as below, where Activator is the activator of the plug-in
that has the data files?

Bundle bundle = Activator.getDefault().getBundle();
URL url = bundle.getResource(relative_plugin_filepath);

Will have to test them out with a deployed (jar file) plug-in.
Re: How to access/read files bundled in your plug-ins as jar files? [message #503111 is a reply to message #502408] Thu, 10 December 2009 22:04 Go to previous message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
AL wrote:
> Francis Upton wrote:
>> You can do something like this:
>>
>> Bundle bundle = Platform.getBundle("your.plugin.id"); //$NON-NLS-1$
>> URL url = bundle.getResource("nameoffile");
>>
>>
>
> Same thing as below, where Activator is the activator of the plug-in
> that has the data files?
>
> Bundle bundle = Activator.getDefault().getBundle();
> URL url = bundle.getResource(relative_plugin_filepath);
>
> Will have to test them out with a deployed (jar file) plug-in.

That works! Tested with deployed a plug-in, where my plug-in jar file
contain data files.
Previous Topic:[CVS] syncrhonize not working
Next Topic:Eclipse Command farmework
Goto Forum:
  


Current Time: Tue Mar 19 03:01:07 GMT 2024

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

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

Back to the top