I'm able to read the Manifest file inside of my Java code, but I would also like to know if it's possible, and if it is, how to open up a JAR file from the command line and view its Manifest.MF file, or at the very least be able to specify a property of the Manifest.MF file and view it's value.
7 Answers
From here:
You can extract selected entries from a jar file. For instance, if you only want to view the meta-inf/manifest.mf file, you can
C:\Sun\AppServer\lib>jar xvf j2ee.jar META-INF/MANIFEST.MF
inflated: META-INF/MANIFEST.MF
Or using a backslash instead of a forward slash:
C:\Sun\AppServer\lib>jar xvf j2ee.jar META-INF\MANIFEST.MF
inflated: META-INF/MANIFEST.MF
The entry names are case sensitive, and so the following will not extract anything:
C:\Sun\AppServer\lib>jar xvf j2ee.jar meta-inf/manifest.mf
Of course, you can always double-click the entry to view it in WinZip, fileroller, or other tools.

- 1,262,500
- 529
- 4,410
- 5,250
-
i'm guessing he needs it programatically, so your first bit would be most appropriate. – geowa4 Jul 10 '09 at 13:50
Something like this should work:
jar -xf <jarfile.jar> META-INF/MANIFEST.MF

- 21,945
- 4
- 50
- 55
it looks like the unzip command will help you -- it's available on most Un*x variants and is part of cygwin as well, if you are on Windows. unzip -qc *jar-file* META-INF/MANIFEST.MF
will dump the contents of the manifest to the console.

- 2,189
- 13
- 14
the jar executable provided by JDK works the same way tar works on linux.
jar xvf for example .... See jar options.

- 18,554
- 22
- 89
- 134
Properties for runtime should not be defined in the manifest, they should be defined in separated config files that follow the Java Properties style. Assuming you are checking the manifest at runtime for whatever reason.
But if you need to:
jar xvf somejar.jar META-INF/MANIFEST.MF
will inflate the manifest for your viewing pleasure.

- 40,390
- 17
- 88
- 107
There is not a way with the jar
command; the closest you can get is to use -tf
to show the presence or absence of a META-INF/MANIFEST.MF
file or -xf
to extract it.
Work-arounds:
- You could write your own class to do this
- You could use any ZIP file viewer to extract the contents - many will write the contents of a file in an archive to stdout so that it can be piped into another command (remember,
jar
files are just a specific usage ofzip
files)

- 23,931
- 5
- 55
- 71
You can just use vi for that. If you want to make sure that you don't change the file, open with with -R switch (for readonly). e.g:
vi -R sample-1.0.0-SNAPSHOT.jar
You can navigate to the zip file with the up/down arrow, or search with / e.g.:
/MANIFEST.MF
To exit type the following sequence
:q <Enter>

- 787
- 1
- 8
- 12