• Post Reply Bookmark Topic Watch Topic
  • New Topic

Icon image is not visible by directly opening jar file  RSS feed

 
SunilK Chauhan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
SunilK Chauhan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!