*
The moose likes Java in General and the fly likes Accessing images in a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing images in a jar file" Watch "Accessing images in a jar file" New topic
Author

Accessing images in a jar file

Ali Yuruz
Greenhorn

Joined: Oct 10, 2007
Posts: 8
Hallo,
At first I must say, Everything works in Eclipse.

I generate a jar file with Ant. When I start the program i doesn't find the images.

I do it like:
In eclipse there are two folders. One is src (for java files). The other is images(for images).
I put the classes and images in jar file with the following structure
-classes
-images
-META-INF

The code to read images is like:


Help!!!

SCJP
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Resources inside jars should be accessed using getClass().getResource() or getClass().getResourceAsStream()


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ali Yuruz
Greenhorn

Joined: Oct 10, 2007
Posts: 8
How will be the code for my case??

Thanks.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2153
    
    7
Read the section from the Swing tutorial on How to Use Icons.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing images in a jar file
 
Similar Threads
images in jar file
jar file probelm
how do you load images from a jar file for image buttons?
Problems with Image Icons in Forte 3.0
Icons and Images question