aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading Manifest File" Watch "Reading Manifest File" New topic
Author

Reading Manifest File

Joel Boeder
Greenhorn

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!
Joel
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Maybe this conversation would help?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading Manifest File