Reputation: 1794
I'm working on a project and compiling and running through my IDE works fine. All resources are found and it works properly. However, when I build my .jar it's able to find some resources but not all. My project structure looks like so:
src
res
image.png
image1.png
about.html
tmp
somefilehere.txt
myFile.java
When I run my jar file it's able to find the images and use them, however when I try to access the html file it won't open. Here's what the project structure for the jar;
I haven't messed around with jar files before so this may seem very obvious mistake I am making. Any help is appreciated thanks!
EDIT: Code that accesses the file which isn't being found,
private void openURL(String url) {
try {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
}
...catch exceptions...
}
EDIT: Structure of the jar file looks like,
META-INF
res
image.png
image1.png
about.html
tmp
somefile.txt
myclass.class
Upvotes: 0
Views: 1394
Reputation: 362
First of all make sure that you've all resources in project folder. While building jar, you need to attach working directory. Make sure that directory contain resources. I tried out it in netbeans & jar is working fine showing images. What I usually do... I select src folder as working project folder & that folder contain res folder for images. Try it. I hope it would help.
Upvotes: 1