Issues with loading a resource file in a plugin.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Issues with loading a resource file in a plugin.

Volodymyr Babin
Hi,

I have yet another issue to be resolved, this seems to be the very basic one, yet I can't solve it for now.

I need to load an resource xml file to get some more autocomletion options. So I load and parse it by using:
======
new File("src/com/forcenb/resources/autocomplete.xml");
======

While it, again, works perfectly in the Run/Debug environment, when it gets installed into the Netbeans as a plugin, IDE log shows it cannot find that file, and a path it refers to starts with Netbeans root folder, e.g. <netbeans_root>/src/com/forcenb/resources/autocomplete.xml.

How do I solve this?

Thanks a lot.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issues with loading a resource file in a plugin.

Peter Nabbefeld
Hi Volodymyr,

as modules don't have the "src" folder, You cannot get the resource from
it. Even more, the file will not be distributed outside Your module, so
You'll not even find it anywhere in the netbeans subdirectories, so You
have to get it from within Your module.

So, Your resource file is only available via the classloader, so You
should access it like:

SomeClass.class.getResourceAsStream("com/forcenb/resources/autocomplete.xml");

Kind regards
Peter



Am 17.07.2017 um 09:26 schrieb Volodymyr:

> Hi,
>
> I have yet another issue to be resolved, this seems to be the very basic
> one, yet I can't solve it for now.
>
> I need to load an resource xml file to get some more autocomletion
> options. So I load and parse it by using:
> ======
> new File("src/com/forcenb/resources/autocomplete.xml");
> ======
>
> While it, again, works perfectly in the Run/Debug environment, when it
> gets installed into the Netbeans as a plugin, IDE log shows it cannot
> find that file, and a path it refers to starts with Netbeans root
> folder, e.g. <netbeans_root>/src/com/forcenb/resources/autocomplete.xml.
>
> How do I solve this?
>
> Thanks a lot.
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issues with loading a resource file in a plugin.

Volodymyr Babin
Hi Peter,

This is awesome, I tried and it works just fine. Thanks a lot!

Regards,
Volodymyr

--- Оригінальне повідомлення ---
Від кого: "Peter Nabbefeld" <[hidden email]>
Дата: 28 липня 2017, 11:32:06

Hi Volodymyr,

as modules don't have the "src" folder, You cannot get the resource from 
it. Even more, the file will not be distributed outside Your module, so 
You'll not even find it anywhere in the netbeans subdirectories, so You 
have to get it from within Your module.

So, Your resource file is only available via the classloader, so You 
should access it like:

SomeClass.class.getResourceAsStream("com/forcenb/resources/autocomplete.xml");

Kind regards
Peter



Am 17.07.2017 um 09:26 schrieb Volodymyr:
> Hi,
> 
> I have yet another issue to be resolved, this seems to be the very basic 
> one, yet I can't solve it for now.
> 
> I need to load an resource xml file to get some more autocomletion 
> options. So I load and parse it by using:
> ======
> new File("src/com/forcenb/resources/autocomplete.xml");
> ======
> 
> While it, again, works perfectly in the Run/Debug environment, when it 
> gets installed into the Netbeans as a plugin, IDE log shows it cannot 
> find that file, and a path it refers to starts with Netbeans root 
> folder, e.g. <netbeans_root>/src/com/forcenb/resources/autocomplete.xml.
> 
> How do I solve this?
> 
> Thanks a lot.
> 


Loading...