• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Manifest file woes

 
Tim Manchester
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1366
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1366
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic