aspose file tools*
The moose likes Java in General and the fly likes Jar and Images Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Jar and Images Problem" Watch "Jar and Images Problem" New topic
Author

Jar and Images Problem

TJ Hylton
Greenhorn

Joined: Jul 27, 2002
Posts: 12
I really need help here... The following was typed
at the command line
jar cfm Bank.jar manifest.mf *.class images/*.*
a subsequent Bank.jar was created. It worked perfectly in the folder where it originated but outside that diretory the images do not appear.
the manifest file has
Main-class: Banking
when i type
jar tf Bank.jar
i get this...
META-INF/
META-INF/MANIFEST.MF
Banking.class
BankPassWord.class
images/logo.jpg
iages/side.gif
what is the problem here?


TJ Hylton
omar khan
Ranch Hand

Joined: Feb 01, 2001
Posts: 183
I am not sure to have understood your problem.
From what you wrote the jar file seems to contain the images directory as you wanted.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hey TJ,
When you move the jar file to another directory, you need to make sure that the jar file is in your CLASSPATH, otherwise it is not visible to the Java Runtime.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
TJ Hylton
Greenhorn

Joined: Jul 27, 2002
Posts: 12
Micheal what do you mean by "you need to make sure that the jar file is in your CLASSPATH". I'm confused.
Omar the images do not appear in the application once the jar file is relocated to another directory.
[ August 07, 2002: Message edited by: TJ Hylton ]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi TJ,
I think that I may have led you astray on the CLASSPATH. The problem is you are probably loading the images from a file instead of from a resource. You need to create a URL like this:

That will load up the image in the jar file instead of the file located at ./images/logo.jpg.
Hope this helps,
Michael Morris
TJ Hylton
Greenhorn

Joined: Jul 27, 2002
Posts: 12
Micheal I think I see where you are going with the url thing...(I'm just not sure)
I used a JLabel to store the image... how do i use the url instead?
welcome=new JLabel(new ImageIcon("images/logo.jpg"));
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi TJ,
Try this:

This should do what you want.
Michael Morris
TJ Hylton
Greenhorn

Joined: Jul 27, 2002
Posts: 12
It worked Micheal! I LOVE YOU!
THANKS!!
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
I hope this doesn't mean we have to get married, since I already have a wife and five kids!

Michael Morris
TJ Hylton
Greenhorn

Joined: Jul 27, 2002
Posts: 12
lol. Micheal your safe. I'm not ready to be barefeet,pregnant and in the kitchen either.
You were a lot of help though. thanx
 
Consider Paul's rocket mass heater.
 
subject: Jar and Images Problem