| Caj Zell 2006-08-18, 10:01 pm |
| I have the following problem:
I have a java-application that includes a few jpgs as background and
icons. I include them with the following code:
image = Toolkit.getDefaultToolkit().getImage("pic.JPG");
repaint();
and
URL url = getClass().getClassLoader().getResource("pic2.JPG");
JLabel rightImage = new JLabel( new ImageIcon(url));
This works fine when I run this application with java. Then I made a
jar-file out of it with the following command:
..../jdk1.5.0_01/bin/jar -cvmf myManifest.mf app.jar *.class pic.JPG
pic2.JPG
If I run this jar-file from that directory with
java -jar app.jar
everything goes well, but if I move it to another directory and run it
with the same command, it won't find the jpgs, even though I can see
them if I list the jar-files contents with
jar tf app.jar
Shouldn't it be possible to just run the tar-file and assume every file
is ready to use?
|