Using Java to read a .jar manifest file

Kyle

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...

Robin Green

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Using Java to read a .jar manifest file

From Dev

Unable to read jar manifest with java.util.jar.JarFile

From Dev

How to configure a manifest file of a jar file by using the maven assembly plugin?

From Dev

Read manifest from JAR with gradle

From Dev

Read manifest from JAR with gradle

From Dev

Java can't execute jar file no main manifest attribute

From Dev

"no main manifest attribute" after downloading a .jar file in Java

From Dev

Add Classpath in Manifest file of jar in gradle in java 8

From Dev

Updating jar manifest file - java.io.IOException: invalid manifest format

From Dev

Updating jar manifest file - java.io.IOException: invalid manifest format

From Dev

Read a file from a jar file, the jar generated using netbeans

From Dev

Confusion on Uses of Jar Manifest File

From Dev

How to read a file from JAR using NIO?

From Dev

Ho to read .java file in executable jar

From Dev

Java jar - no main manifest attribute

From Dev

Error opening zip file or JAR manifest missing : /usr/share/java/jayatanaag.jar

From Dev

Read properties file outside JAR file - java 8 not recognizing file

From Dev

Java manifest file

From Dev

Reading Manifest.mf in war file using java

From Dev

Read Json file using Java

From Dev

no main manifest attribute (But I have the manifest file in the jar)

From Dev

Exporting Jar file with Manifest attribute in Android Studio?

From Java

Replacing the MANIFEST.MF file in a JAR programmatically

From Dev

Jar command not adding requested manifest file to archive

From Dev

JAR Manifest file - Difference between Specification and Implementation

From Dev

JAR file manifest does not contain permission attribute

From Dev

add manifest to compiled exe file from jar

From Dev

"-includeresource" in JAR Manifest inside Gradle build file

From Dev

Updating the manifest and overwriting duplicate entries using jar

Related Related

  1. 1

    Using Java to read a .jar manifest file

  2. 2

    Unable to read jar manifest with java.util.jar.JarFile

  3. 3

    How to configure a manifest file of a jar file by using the maven assembly plugin?

  4. 4

    Read manifest from JAR with gradle

  5. 5

    Read manifest from JAR with gradle

  6. 6

    Java can't execute jar file no main manifest attribute

  7. 7

    "no main manifest attribute" after downloading a .jar file in Java

  8. 8

    Add Classpath in Manifest file of jar in gradle in java 8

  9. 9

    Updating jar manifest file - java.io.IOException: invalid manifest format

  10. 10

    Updating jar manifest file - java.io.IOException: invalid manifest format

  11. 11

    Read a file from a jar file, the jar generated using netbeans

  12. 12

    Confusion on Uses of Jar Manifest File

  13. 13

    How to read a file from JAR using NIO?

  14. 14

    Ho to read .java file in executable jar

  15. 15

    Java jar - no main manifest attribute

  16. 16

    Error opening zip file or JAR manifest missing : /usr/share/java/jayatanaag.jar

  17. 17

    Read properties file outside JAR file - java 8 not recognizing file

  18. 18

    Java manifest file

  19. 19

    Reading Manifest.mf in war file using java

  20. 20

    Read Json file using Java

  21. 21

    no main manifest attribute (But I have the manifest file in the jar)

  22. 22

    Exporting Jar file with Manifest attribute in Android Studio?

  23. 23

    Replacing the MANIFEST.MF file in a JAR programmatically

  24. 24

    Jar command not adding requested manifest file to archive

  25. 25

    JAR Manifest file - Difference between Specification and Implementation

  26. 26

    JAR file manifest does not contain permission attribute

  27. 27

    add manifest to compiled exe file from jar

  28. 28

    "-includeresource" in JAR Manifest inside Gradle build file

  29. 29

    Updating the manifest and overwriting duplicate entries using jar

HotTag

Archive