Images in jar files
Posted on 2000-05-16
How can I tell the java interpreter where to look for image files in a Jar file?
For example, I have a class called "MyClass.class" and an image file called "MyImage.jpg". The constructor of MyClass will create an instance of ImageIcon("MyImage.jpg"). Now I want to package MyClass.class into a Jar file and I also want to include "MyImage.jpg" in that jar file as well.
However, the java interpreter seems to expect MyImage.jpg from the directory where the main Class is stored. Even though "MyImage.jpg is in the same archive as "MyClass.class", MyClass won't be able to find MyImage.jpg unless there is another MyImage.jpg in the directory where the main Class resides.
How can I tell the java intepreter to look for "MyImage.jpg" in the archive that MyClass.class comes from? Is there any work-around or something?