This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Images in a JAR" Watch "Images in a JAR" New topic
Author

Images in a JAR

Andrew Honma
Greenhorn

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:

Project_Name
|
|_src (folder)
|image_name.xxx

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.

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

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
sscce.org
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
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.
 
Don't get me started about those stupid light bulbs.
 
subject: Images in a JAR
 
Similar Threads
Problems building and running program
Having issue accessing images inside jar
jax-ws in glassfish server
Loading Images
LWJGL/Slick TextureLoader issue