Hi,
I want to load images from one package to another packages but it can't load that in Java Swing when running from a .jar-file
Plz guide me...
Can not load the images in Java Swing when running from a .jar-fileCan not load the images in Java Swing when running from a .jar-file
Page 1 of 1
4 Replies - 2341 Views - Last Post: 19 January 2011 - 03:49 AM
#1
Can not load the images in Java Swing when running from a .jar-file
Posted 12 January 2011 - 03:21 AM
Replies To: Can not load the images in Java Swing when running from a .jar-file
#2
Re: Can not load the images in Java Swing when running from a .jar-file
Posted 12 January 2011 - 03:45 AM
getResourceAsStream not FileInputStream (if that's what you're doing). In any case, it would probably help to
1. See the code
2. Know the complete path to the jar file
3. Know the complete path to the images
4. Know if the images are located in the jarfile
5. Know the complete package of the class
6. Know the location of the images in relation to the package of the class loading them
1. See the code
2. Know the complete path to the jar file
3. Know the complete path to the images
4. Know if the images are located in the jarfile
5. Know the complete package of the class
6. Know the location of the images in relation to the package of the class loading them
#3
Re: Can not load the images in Java Swing when running from a .jar-file
Posted 12 January 2011 - 03:46 AM
Keep your images in /images and then load thus:
Image i = javax.imageio.ImageIO.read(getClass().getResourceAsStream("/images/x.png"));
#4
Re: Can not load the images in Java Swing when running from a .jar-file
Posted 19 January 2011 - 03:27 AM
I have made changes but still i am unable to run jar file with image.
Plz guide me
Plz guide me
#5
Re: Can not load the images in Java Swing when running from a .jar-file
Posted 19 January 2011 - 03:49 AM
Please post
a. Loading code
b. The output of
a. Loading code
b. The output of
jar tf yourjar.jar
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|