Skip to main content

request for new option allowing jar to send contents to stdout

No replies
Joined: 2006-07-05

I am often using the command line performing a 'ls' on a directory full of jar files from various sources. Many times I would just like to see the text of some of the jar files contents such as META-INF/MANIFEST.MF or WEB-INF/web.xml, etc. Currently I must unjar the file, cat the contents and delete the file and its associated directory structure. While doing a recursive delete of a directory structure is usually harmless, there is some risk involved.

What would solve all of these problems is if I could use a command like this:

jar sf jre/lib/rt.jar META-INF/MANIFEST.MF

The 's' option to the jar command would just send META-INF/MANIFEST.MF to stdout. Alternitively you cold add an option to choose the output stream,

Usage: jar {ctxu}[vfm0Mi] [jar-file] [manifest-file] -X [stream] [-C dir] files ...

where -X specifies where to send the bits you are extracting to [stream] which could be stdout stderr or file. The default would be to send everyting to file.

Since I already can use stdin with the jar command,

cat "jre/lib/rt.jar" | jar xv META-INF/MANIFEST.MF

I should also be able to use stdout:

cat "jre/lib/rt.jar" | jar xv -X stdout META-INF/MANIFEST.MF | grep Version

This change should be backwards compatible with the current jar command and should be simple to implement. Please make this available in the jar in jse6 and even jse5.