This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having issue accessing images inside jar

 
Rite Sara
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have created one swings application using Eclipse IDE. I want to use it by creating a jar file.
The app has many images used in the panels as well as tables. These images are displayed properly when I run my project in eclipse.
But when I make a jar these images are not displayed.

Here is the way I am using images :

My project folder is on desktop having following path and I am storing images inside Create 2\images .. where Create 2 is the name of my project folder or project.

C:\Documents and Settings\25466\Desktop\Create 2\images

Then I am referring these images inside code using following path :

ImagePanel panel = new ImagePanel(new ImageIcon("images/banner.PNG").getImage());
this.jPanel1.add(panel);

Please let me know what is going wrong ..where I can place the images folder so that they are displayed in the jar too...
 
Rite Sara
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to resolve this issue ... I used following code ...

URL imageURL = getClass().getClassLoader().getResource("images/banner.PNG");
ImagePanel panel = new ImagePanel(new ImageIcon(imageURL).getImage());
this.jPanel1.add(panel);

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic