• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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: 5035
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.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic