Reputation: 116187
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.
Upvotes: 4
Views: 1740
Reputation: 807
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>
Upvotes: 0
Reputation: 2219
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.
Upvotes: 2
Reputation: 24309
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:
jar
files are just a specific usage of zip
files)Upvotes: 1
Reputation: 41833
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.
Upvotes: 1
Reputation: 22487
Something like this should work:
jar -xf <jarfile.jar> META-INF/MANIFEST.MF
Upvotes: 2
Reputation: 1326676
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.
Upvotes: 5
Reputation: 19060
the jar executable provided by JDK works the same way tar works on linux.
jar xvf for example .... See jar options.
Upvotes: 1