Forums Register Login

Icon image is not visible by directly opening jar file

+Pie Number of slices to send: Send
Hello friends,

i have made one swing application and inserted icon image into it using netbeans ide.
when i open my class using netbeans than icon is displaying properly but opening by directly clicking an jar file it is not showing.

i have pasted my code here.


Why it is?
+Pie Number of slices to send: Send
Maybe the location of the image file is wrong. We need more details, including the locations of the image in the NetBeans folders and in the .jar. And why are you not using Class#forName#getResource or similar?
+Pie Number of slices to send: Send
 

SunilK Chauhan wrote:
when i open my class using netbeans than icon is displaying properly but opening by directly clicking an jar file it is not showing.



Resources from within a jar need to be accessed via the Class#getResource() or Class#getResourceAsStream()

More about it here
https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html
+Pie Number of slices to send: Send
Yes guys.

It's working. It's the issue of image fetching properly from the resources. Now I can view the image from jar file also.
Thank you guys.
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 431 times.
Similar Threads
jar wont load image
Reading icon using ImageIO.Read
change the icon of .jar file
Icons and Images question
How to increase the size of title image in a swing application???
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:51:41.