Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jar and Images Problem

 
TJ Hylton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
omar khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
TJ Hylton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi TJ,
Try this:

This should do what you want.
Michael Morris
 
TJ Hylton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked Micheal! I LOVE YOU!
THANKS!!
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic