I am creating a program that uses gifs and jpgs as graphics. Those are stored in a folder called "Graphics". When I compile and run my program from the command line, everything is fine. But as soon as I put it in a JAR file and execute it, the graphics don't show. I tried putting the graphics folder into the jar file, but that didn't help.
Joined: Jan 17, 2006
How are you currently trying to load the images from the .jar?
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Joined: Sep 09, 2006
This is an example how I load the graphics.
When I just compile it and try it out I have the graphics folder in the same folder as the class files and it works. When I put it in a JAR I put the Graphics folder in the same folder as the JAR file and it did not work. Then I tried putting the Graphics folder in the JAR and that did not work, either
Joined: Mar 22, 2005
Regular file I/O does not work with resources in jar files. You need to use the resource/classloader approach, which will look something like this (assuming that 'Graphics' is a top-level directory in the jar file):