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] Fri, 04 December 2009 22:33 Go to next message
Alex Le is currently offline Alex Le
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 04:34 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IV
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] Mon, 07 December 2009 21:45 Go to previous messageGo to next message
Alex Le is currently offline Alex Le
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 17:04 Go to previous message
Alex Le is currently offline Alex Le
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: Wed Apr 16 12:21:36 EDT 2014

Powered by FUDForum. Page generated in 0.11308 seconds