File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 42965
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
jQuery in Action, 3rd edition