Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Images in a JAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Images in a JAR" Watch "Images in a JAR" New topic

Images in a JAR

Andrew Honma

Joined: Jul 19, 2008
Posts: 1
I am using images as textures in a small program I'm playing with.

When I create a the JAR file, I include the images (I am using Eclipse, and have the image files check-marked).

However, running the JAR fails to load those images.

The images load just fine when the program is run within the Eclipse IDE.

I am using images with java 3D, for example:

The images are currently saved under the Project_Name directory:

|_src (folder)

However, moving the images around and changing the path will continue to allow it to work in the Eclipse IDE but not when exported to a JAR.

Please let me know if any more info needs to be supplied to help with this.

[ July 19, 2008: Message edited by: Drew ]
marc weber

Joined: Aug 31, 2004
Posts: 11343

"Drew," welcome to JavaRanch! Please check your private messages by clicking on My Private Messages. Thanks!

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 696
If the images are in the jar file and NOT on disk, you need to access them using classes/methods that know how to look in a jar file. I don't know about the TextureLoader class.
You can use the getResourceAsStream() method to read the image.
Check the constructors for TextureLoader to see if it can get its input from another source.
I agree. Here's the link:
subject: Images in a JAR
It's not a secret anymore!