This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Image inside jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Image inside jar file" Watch "Image inside jar file" New topic

Image inside jar file

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

Dear friends,

I have to display some icons in the GUI which i create. I have included the following gif files in the code:

I created a seperate icon package and copied all those images inside this package.
When i create an executable jar and run it, these icon images are not getting displayed in the interface.

Kindly provide your help in resolving this problem.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
The ImageIcon(String) constructor expects a file name as parameter, so that won't work. Something like the following should do the trick:

You may have to fiddle around with the path name, and whether or not there needs to be a slash in front of it.
I agree. Here's the link:
subject: Image inside jar file
It's not a secret anymore!