Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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

 
Ranch Hand
Posts: 93
  • 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?
 
Marshal
Posts: 60748
189
  • 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?
 
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: 93
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!