Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read MANIFEST.MF file from JAR using Bash

I need to read MANIFEST.MF maven manifest file from "some.jar" using bash

like image 829
Roman Avatar asked Aug 15 '11 14:08

Roman


People also ask

How do I read a jar file manifest?

MF from a jar in a single command" mentions that the "old way" to view a manifest file was often to create a temporary directory, copy the JAR of interest into that temporary directory, change directory to that temporary directory, unzip the JAR file's contents, view the file of interest, and then remove the temporary ...

How do I unpack a jar file?

JAR files work just like ZIP files. You can use any archive program to extract them. On Windows, you can Install WinRAR 7-Zip, or WinZIP. Macs have their own built-in archive program called Archive Utility.

How do you find manifest mutual funds?

The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections.


1 Answers

$ unzip -q -c myarchive.jar META-INF/MANIFEST.MF 
  • -q will suppress verbose output from the unzip program
  • -c will extract to stdout

Example:

$ unzip -q -c commons-lang-2.4.jar META-INF/MANIFEST.MF  Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.0 Created-By: 1.5.0_13-119 (Apple Inc.) Package: org.apache.commons.lang Extension-Name: commons-lang Specification-Version: 2.4 Specification-Vendor: Apache Software Foundation Specification-Title: Commons Lang Implementation-Version: 2.4 Implementation-Vendor: Apache Software Foundation Implementation-Title: Commons Lang Implementation-Vendor-Id: org.apache X-Compile-Source-JDK: 1.3 X-Compile-Target-JDK: 1.2 

Alternatively you can use -p instead of -q -c.

-p extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary format, just as they are stored (no conversions).

like image 140
miku Avatar answered Sep 21 '22 13:09

miku