• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Manifest file woes  RSS feed

 
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
 
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.
 
Rancher
Posts: 3353
33
  • 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.
 
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
Rancher
Posts: 3353
33
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!