This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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.
Joined: Aug 10, 2005
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.