• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing images in a jar file

 
Ali Yuruz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resources inside jars should be accessed using getClass().getResource() or getClass().getResourceAsStream()
 
Ali Yuruz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How will be the code for my case??

Thanks.
 
Rob Camick
Ranch Hand
Posts: 2600
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the section from the Swing tutorial on How to Use Icons.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic