• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading images from a JAR file on build path  RSS feed

 
Jack Bernstein
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jar file of a bunch of images. I'd like to be able to read an image from the file. I know how to do this if I just put the jar into my project, but how do you do this when the jar is included as a library on your build path? It doesn't seem to work the same.

Below is a test program that works if the jar is included in my project, but does not work when the jar is included in the build path.



Thanks in advance for any help!
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out how Class.getResource and ClassLoader.getResource (and their helper methods getResourceAsStream) work.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!