Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JAR Files

Status
Not open for further replies.

djabell

Instructor
Apr 9, 2001
44
GB
I have a small GUI-based application with a number of gif files for image icons in a directory called 'data'. When I package the class files into a JAR file, the program still runs but the buttons don't contain any images. However, when I run the program outside of an archive, the problem disappears. Any ideas?
 
Have you specifically include the jar file in your classpath ?
 
No - I've modified the manifest file and I invoke the app as java -jar ....

Thanks anyway.
 
Hi,

I know it sounds obvious but .....

What about the path your app uses to look for the images? Were they in another folder or something before u packaged it into a jar?
 
Hi,

Did you solve your problem? If so how? I'm reading in .gif files for a button icon and even though the ImageIcon constructor is not throwing an exception (implies the gif file was found OK and no permission failures occured) the icons are not being drawn on the buttons.

These blank buttons only occur when running the applet in a web browser they work fine when I run using appletviewer.

Thanks Andy
 
Yes. Before using JAR file, I read in the image files as follows:

Image i = Toolkit.getDefaultToolkit().getImage("file.gif");

I now read in the images files as follows:

URL url = JiCGUI.class.getResource("myfile.gif");
img = Toolkit.getDefaultToolkit().getImage(url);

The JiCGUI is the name of the class where I read in the image files. This now works fine.

David Bell

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top