morti
asked on
Image in JAR not found/used
I have a gif image that is called by a JLabel:
JPanel cp = new JPanel(new GridLayout(0,2));
cp.add(new JLabel(new ImageIcon("test.gif")));
I produced a jar by using this command: "jar cvfm MyApp.jar manifest.txt *.class test.gif"
The jar is correctly created and the image is shown if the jar is run in a directory that contains "test.gif" (the contents of the directory are MyApp.jar and test.gif). If the gif isn't in the same directory, the image won't show. What am I doing wrong?
Thank you! :)
JPanel cp = new JPanel(new GridLayout(0,2));
cp.add(new JLabel(new ImageIcon("test.gif")));
I produced a jar by using this command: "jar cvfm MyApp.jar manifest.txt *.class test.gif"
The jar is correctly created and the image is shown if the jar is run in a directory that contains "test.gif" (the contents of the directory are MyApp.jar and test.gif). If the gif isn't in the same directory, the image won't show. What am I doing wrong?
Thank you! :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
ASKER
cp.add(new JLabel(new ImageIcon( this.getClass().getResourc