This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't "see" image inside the jar file

 
Orna Vel
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I created the .jar file for distribution. There are some .class files there and an Image directory with several .gif files I use as icons.
I run the application with the command:
java -classpath ".;MyJar.jar" MainClass
Everything runs fine, but there are no icons on my GUI :-(. It works fine if I copy the Image directory to current directory (.). But I do not want to do it.
When I use
jar -tf MyJar.jar I can see, that Image directory with all gifs is there.
How can I avoid copying the Image directory?

Thank you.
:roll:
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use one of the getResource... methods.

usually that would go something like
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Steven suggests, the problem is probably with the methods you use to load the images. If you can post the code that does this, we can help give more specific suggestions how to fix it. I think Steven's suggestion for using the getResource() methods will probably help. If not please post some code so we can help further. You should also google for more information about using resources in Java.

Layne
 
Orna Vel
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much, gurus. My code looks like this:


etc.

Where:

I'll try to find another way to deal with this names.
[ May 25, 2005: Message edited by: Orna Vel ]
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to fix it by changing this line

to
 
Orna Vel
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, it works now.

 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic