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

Peter Nabbefeld <[email protected]> Fri, 28 Jul 2017 10:30:50 +0200
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
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.
>