aspose file tools
The moose likes Java in General and the fly likes How to load a resource in a .jar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to load a resource in a .jar" Watch "How to load a resource in a .jar" New topic
Author

How to load a resource in a .jar

Charles Mulloy
Ranch Hand

Joined: Oct 25, 2009
Posts: 30
I've looked around and couldn't figure out how this is done.

I'm trying to load an image in a .jar, but the jar is executable. Both the main class and the image are in the same .jar. I'm trying to use the setIconImage() method. I'm using the code HERE to learn how. It works perfectly outside the jar, but not inside. How do I tell java to access files inside the jar?
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

http://www.java-tips.org/java-me-tips/midp/how-to-read-a-resource-from-a-jar-file.html


- Chinna
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32644
    
    4
There should be something in the Java™ Tutorials about how to put your image in a .jar. Try putting the image in the top-level folder you are zipping; it might be a problem with the location of the image file.

I think this is too difficult for "beginning".Moving thread.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: How to load a resource in a .jar
 
Similar Threads
How to turn a byte[] into an image?
Loading an Image
Displaying Images that are insigned Applet
Trouble loading image as resource :(
Loading Resources within *.jar