Reputation: 15
Hello I'm having a bit of trouble with resource loading in .jar. In eclipse, I create image files with the path "data//guis//play.png" but when I try to run the jar, i get the exception that the resource could not be found, even when packaged in the same structure as I have it within eclipse. How do I rememdy this?
Upvotes: 0
Views: 426
Reputation: 285415
You state:
Hello I'm having a bit of trouble with resource loading in .jar. In eclipse, I create image files with the path "data//guis//play.png" but when I try to run the jar, i get the exception that the resource could not be found, even when packaged in the same structure as I have it within eclipse. How do I rememdy this?
But that's exactly what your problem is likely due to -- you're trying to create files and files don't exist inside of Jars (as Java sees it). Instead load the images as resources not as files.
For more detailed help, you will want to show more of your pertinent code as well as the structure of your jar file.
Please run this from the command line and show the result here:
jar tf MyJarFile.jar
Of course you'll use your jar file name when you run this line.
Upvotes: 1