Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Add Image on to JFrame in jar file

 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,



I have a jar file. After run it's "source" code I can see the JFrames with images. But if I run it's jar file their are no any image on jframes. my java file and other images are in same directory. how can I make a jar file with this all files. because if i give this jar file and images to other person he can edit the images that he want. So haw can I build a jar file that hold all images and class files? Please help me.

Thank you.
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Class.getResource to get a URL to the resource (inside the JAR file), then use that resource to create the ImageIcon.
 
muntago Richard
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to understand your question, You said that when you run the applications that it was perfect but now you wish to make it executable such eg example.jar and to that effect, the image is not displaying, is that your question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic