aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes executable jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "executable jar file" Watch "executable jar file" New topic
Author

executable jar file

ravindra janapreddy
Ranch Hand

Joined: Jan 30, 2001
Posts: 84
Hi
While creating the above , I came upon this issue of what someone like me who had downloaded jdk 1.4.0_01 and renames it as jdk1.4 on his/her machine. In that case when one creates jar file one may end up setting up something like this
manifest file 1
Manifest-Version: 1.0
Created-By: 1.4 (Sun Microsystems Inc.)
Main-Class: suncertify.client.FBNTable
instead of
manifest file 2
Manifest-Version: 1.0
Created-By: 1.4.0_01 (Sun Microsystems Inc.)
Main-Class: suncertify.client.FBNTable
in that case when you try to execute the jar file using manifest file 1 then you get an error
so is there a way to avoid this ? How do we ensure that the examiner has modified the environment file or other files with the right values ? Do we explicitly ask the examiner to modify the manifest file with appropriate version of jdk on his machine ?
Thanks
Ravi


SCEA, SCBCD, SCWCD, SCJD, SCJP
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Ravi, is this for the Beta exam?
If it isn't, I'd suggest going back to SDK 1.3. And keep the defaults of the installation.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Patrick Li
Greenhorn

Joined: Aug 30, 2002
Posts: 11
Hi Mark,
I have a problem to read a image file from a jar file. I have jar all image files under images folder, which is under root, into client.jar. By using:
java -jar client.jar
My application failed to load the images. Here is the code for the image: new ImageIcon("images/exit.gif")
I tried to find if there is header-value needed in Manifest file, Could not find any infomation about this.
Could you or anybody give me some hints about this? Thanks,
Patrick
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Patrick,
You have to load stuff in a jar as a resource and not a file. Here's what you need to do:

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
Patrick Li
Greenhorn

Joined: Aug 30, 2002
Posts: 11
Thanks, Michael.
Your solution: this.getClass().getResource("/images/exit.gif") solved my problem rightway.
does this imply that I could load db.db (default) file from a jar file directly when the users do not provide a path (name) for database file name?
same to other text and properties files, are we supposed to always use getClass().getResourceAsStream or getResource to load the file rather than a file name (System.getProperty("user.dir") + System.getProperty("file.separator")+ filename)? or does this only imply to a jar?
Thanks,
Patrick
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Patrick,

does this imply that I could load db.db (default) file from a jar file directly when the users do not provide a path (name) for database file name?

You can load it, but you can't save it back to the same jar that your application is started from. At least I don't know of a way to do it.

... same to other text and properties files, are we supposed to always use getClass().getResourceAsStream or getResource to load the file rather than a file name (System.getProperty("user.dir") + System.getProperty("file.separator")+ filename)? or does this only imply to a jar?

Only to jar files. You can certainly put property files, etc. in your jar and load them as resources but with the same caveat as above: they are read-only.
Hope this helps,
Michael Morris
 
wood burning stoves
 
subject: executable jar file