so I am trying to see if a .jar is valid or not, by checking some values in the mainfest file. What is the best way to read and parse the file using java? I thought of using this command to extract the file
jar -xvf anyjar.jar META-INF/MANIFEST.MF
But can I just do something like:
File manifest = Command.exec("jar -xvf anyjar.jar META-INF/MAINFEST.MF");
Then use some buffered reader or something to parse the lines of the file?
Thanks for any help...
The problem with using the jar
tool is that it requires the full JDK to be installed. Many users of Java will only have the JRE installed, which does not include jar
.
Also, jar
would have to be on the user's PATH.
So instead I would recommend using the proper API, like this:
Manifest m = new JarFile("anyjar.jar").getManifest();
That should actually be easier!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments