This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading images from a JAR file on build path  RSS feed

 
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!
 
Sheriff
Posts: 21288
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!