Two Laptop Bag
The moose likes I/O and Streams and the fly likes Reading Manifest File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading Manifest File" Watch "Reading Manifest File" New topic

Reading Manifest File

Joel Boeder

Joined: Sep 08, 2003
Posts: 3
I want to read a version number from a Manifest file stored in a JAR file named common.jar. This code clip works:
URL url = new URL("jar:file:/D:/mypath/common.jar!/");
JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
Manifest manifest = jarConnection.getManifest();
String version = manifest.getMainAttributes().getValue("Version-Num);
The problem is that I can only use absolute file paths (d:\mypath\common.jar) to get to the JAR file which will not work when the JAR file is moved around (its running under a servlet on websphere). How do I get the code to use a relative path keeping in mind that the calling class is also located in common.jar?
Alternatively what is the working directory and is even available when running under a servlet (I apologize for asking this in the IO section but it was a toss up on whether this was an IO question or a servlet question)?
Thanks in advance for an answer!
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Maybe this conversation would help?

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Reading Manifest File
jQuery in Action, 3rd edition