Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.gif files in .jar files

Status
Not open for further replies.

bos

Technical User
Oct 1, 2002
50
US
I created a jar file and included all of the class files along with all of the .gif files that go with a program. When I ran the program it did not see the .gif files even though the are included in the .jar.

Please let me know how I might fix this problem. Thanks in advance.
 
You must load the gif as a resource. Try using the following code to load your gifs:

ImageIcon imageIcon = new ImageIcon( getClass().getResource( "/picture.gif" ) );

You must include the directory structure in the call also. So if your gif is picture.gif in the /pics driectory, you would change the call to:

ImageIcon imageIcon = new ImageIcon( getClass().getResource( "/pics/logo.gif" ) );

Hope that helps.

-gc "I don't look busy because I did it right the first time."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top