Reputation: 328
I created a folder called "res" in which I put all the sound files and picture files that my application uses. I added the folder to my project as a library so using
"/filename.whatever"
as the filepath works when I run the project in netbeans. However, when I try to clean and build it says:
Not copying library path\res , it's a directory.
How do I get netbeans to put the folder in the jar so that it still works with the same filepath?
Upvotes: 1
Views: 219
Reputation: 3115
This is the answer of the SAM
This was a pain, using netBeans IDE 7.2.
Add a resource folder to the src folder:
After the clean/build this structure is propogated into the Build folder:
To access the resources:
dlabel = new JLabel(new ImageIcon(getClass().getClassLoader().getResource("**resources/images/logo.png**")));
and:
if (common.readFile(getClass().getResourceAsStream **("/resources/allwise.ini**"), buf).equals("OK")) {
worked for me. Note that in one case there is a leading "/" and in the other there isn't. So the root of the path to the resources is the "classes" folder within the build folder.
Double click on the executable jar file in the dist folder. The path to the resources still works.
Src : How to correctly get image from 'Resources' folder in NetBeans
Upvotes: 2