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
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
posted
0
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
posted
0
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
posted
0
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