• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Images in a JAR

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Drew," welcome to JavaRanch! Please check your private messages by clicking on My Private Messages. Thanks!
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic