jar command can also operate on zip files. I usually run
jar tvf hello.zip to quickly view its content, without starting up the WinZip program.
jar xvf hello.zip should also be able to expand the target zip files. I find it hard to memorize Unix
zip/unzip command line options, so I just use
jar tvf/jar xvf instead. For example:
C:\tmp > jar tvf eclipse-SDK-3.2RC7-win32.zip2.
jar tvfcan selectively list table of contents for archive. I used to run
jar tvf j2ee.jar | grep javax/servlet/httpto search for servlet classes in
findstron Windows. In fact, I don't need
findstr; I can just run this command:
jar tvf j2ee.jar javax/servlet/httpNote that the search criteria are matched against the beginning of all entries in jar file. It uses
String.contains(what). So this command
jar tvf j2ee.jar ejbwill not return any matching entries, though
jar tvf j2ee.jar javax/ejbwill return all ejb classes. The search is also case-sensitive.
If you want case-insensitive search, or match by any parts (not just the beginning) of entries, you still need to use
jar tvf my.jar | grep -i aNynAmE
3. 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.MFOr using a backslash instead of a forward slash:
C:\Sun\AppServer\lib > jar xvf j2ee.jar META-INF\MANIFEST.MFThe entry names are case sensitive, and so the following will not extract anything:
C:\Sun\AppServer\lib > jar xvf j2ee.jar meta-inf/manifest.mfOf course, you can always double-click the entry to view it in WinZip, fileroller, or other tools.