aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Add Image on to JFrame in jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Add Image on to JFrame in jar file" Watch "Add Image on to JFrame in jar file" New topic
Author

Add Image on to JFrame in jar file

dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
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

Joined: Oct 27, 2005
Posts: 19538
    
  16

Use Class.getResource to get a URL to the resource (inside the JAR file), then use that resource to create the ImageIcon.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
muntago Richard
Ranch Hand

Joined: Nov 13, 2010
Posts: 82
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Add Image on to JFrame in jar file
 
Similar Threads
Loading an Image
about splash screen with jar file...
How to load an image from java program
Multiple questions
images in jar file