aspose file tools*
The moose likes Java in General and the fly likes Manifest file woes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Manifest file woes" Watch "Manifest file woes" New topic
Author

Manifest file woes

Tim Manchester
Ranch Hand

Joined: Nov 03, 2004
Posts: 62
I've been working on writing a java app (using WebSphere 5.1.2) that uses a couple of common jar files (log4j, that sort of thing) and I roll everything up in to the same jar file.

The problem is that when I try to run the app out of the jar file (java -jar myapp.jar), it can't find my property files or the other jar files unless I extract them into the same directory as the jar. Could someone post a simple manifest example that shows how to tell the jvm to look inside the current jar for other jar files and property files that the executing app needs?

Regards,

- Tim
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
This is an example:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_04-b05 (Sun Microsystems Inc.)
Class-Path: jdom.jar com.ibm.mq.jar commons-logging.jar connector.jar ejb.jar xercesImpl.jar


Note: make sure you add 1 blank line using a carraige return after the last line in the manifest file.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
How are you reading the files in question? Could you post the code?
Also are there any error messages? Please copy and post those also.
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
The files in the Class-Path are paths and in that example he was using jars located in the same directory. They can be absolute or relative. You use the jar -m switch and give it the name of your manifest when creating the target jar. I think you may have a different problem. Property files are loaded by the classloader of the class that's loading them. So if you are in com.acme.Rocket you can load a property in that folder without specifying any path component.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
I don't think his problem has anything to do with the manifest. It's an I/O problem. Try using the Class.getResourceAsStream() method for reading the properties file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Manifest file woes
 
Similar Threads
Refering a jar file from another jar
read properties file from jar
Set library classpath inside runnable JAR file
refering a property file in the manifest
Jar file preparation