| Author |
jar file help please
|
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
jar cmvf manifest.txt jahok.jar * why wont it keep my images in the jar file, if my jar is in the same folder as the images they show up, but when i move the jar to desktop , it doesnt draw, or read from files its supposed to... Thanks, Justin [ February 05, 2007: Message edited by: Bear Bibeault ]
|
You down with OOP? Yeah you know me!
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
|
Do you use Class/ClassLoader.getResourceXXX() to load the images, which will work out of a jar? Or do you use FileInputStream, file: URLs, or something similar, which won't?
|
[Jess in Action][AskingGoodQuestions]
|
 |
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
i have no clue what either of those are... i just said; i thought when the jar compresses it, it stays with that exe. jar for ever, like a copy of that .GIF file am I wrong? thanks, Justin
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12928
|
|
The API documentation of the constructor of ImageIcon says: public ImageIcon(String filename) ... Parameters: filename - a String specifying a filename or path So it is looking for a file with the specified name. If you don't specify a directory (as you did), it will look for the file in the current directory. If you put your file inside a JAR, then it will not find the file. Have a look at the API documentation for ImageIcon. It has another constructor that takes an URL. You could use that to load the image from a JAR file like this:
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
URL url = MyClass.class.getResource("pic.GIF"); so this code will make the main class look for the pic inside the jar file? if so then thats what i need, however, what i dont need is the jar looking for a file in a certain directory, what i need is for the jar to run the same on different computers... Thanks Again Justin
|
 |
 |
|
|
subject: jar file help please
|
|
|