File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes jar file problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jar file problem" Watch "jar file problem" New topic
Author

jar file problem

Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
Hi,
I've got the following structure:
The workspace is bin (folder)and inside this folder I've got the editor (folder) package and images(folder where there are all the images for the buttons). Inside the editor package is the JTEdi.class, which is the class that has the main method and as well some other packages and more classes inside those packages.
to create the jar file from the command line, I stand in the bin folder and type:
jar cmf manifest.mf jtedi.jar editor images
(insede the bin folder there is a text file manifest.mf which has two lines . the first one is Main-Class: editor.JTEdi, the second one is an empty line)
after that it created a jtedi.jar inside the bin folder and to run it I typed: java -jar jtedi.jar
All that work just perfect, but if I put the jtedi.jar file in another folder and type from the command line the same java -jar jtedi.jar it works but it doesn't display the images on the buttons, intead (I'm using actions) it displays the description of the action.
what could be the problem?
Thanks,


MA Villamizar
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i propose two check Two things
1) Is your images inside your jar ?
2) Are you sure your images respect uppercase and lower case ?If you are working on windows the file system do not care about Casing in the file name but inside the jar it is important!
that's idee i have!
[ July 09, 2003: Message edited by: Benjamin Leonard ]
Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
Leonard,
I tried what u said and still not working.
Everything is in lower case and the images are actually inside the jar file, what else could I do?
Thanks,
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

How are you accessing your images in your code? Through file names? or through Class.getResource()? Check out this helpful Sun Question of the Week...


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
Hi,
I checked the link about the jar file that you gave me. I followed all the steps but now all the all time I get a null value. I tryed as well

but it doesn't work neather. the las method is used to create the image in one of the constructors, but I got another class that extends ActionCommand and is actually the class that get the images,
I wonder if I get the images in the class that contains the main method?

what could be the problem now?
thanks,
Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
hi,
One thing, does the
MyClass.class.getResorce()
has to be in the class that has the main method?
thanks,
Sonny Pondrom
Ranch Hand

Joined: Jun 05, 2001
Posts: 128
You told the jar this:
(inside the bin folder there is a text file manifest.mf which has two lines . the first one is Main-Class: editor.JTEdi, the second one is an empty line)
so the JTEdi.java has to have the main method.
Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
Hi,
Thanks for answer me back, but that is not the problem, if you read my first post on this topic, you will see the problem and as well the answer from nathan pruett. I read the the web he mentioned and the method getResource() always give back a null value I cannot make work.
thanks,
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

How are you loading the images in your app? Are you also putting the images in the JAR file like in the link? Or are you loading them from the file system? If you are going to use a JAR file you should include the images in the JAR.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jar file problem