The basic format of the command for viewing the contents of a JAR file is:jar tf jar-file
- The t option indicates that you want to view the table of contents of the JAR file.
- The f option indicates that the JAR file whose contents are to be viewed is specified on the command line.
- Without the f option, the Jar tool expects a filename on stdin.
- The jar-file argument is the filename (or path and filename) of the JAR file whose contents you want to view.
The t and f options can appear in either order, but there must not be any space between them.
Add the verbose option, v, to add file sizes and last-modified dates to the output.
Use the Jar tool to list the contents of the TicTacToe.jar file created in the previous section:jar tf TicTacToe.jarThis command displays the contents of the JAR file to stdout:
META-INF/MANIFEST.MF
TicTacToe.class
audio/
audio/beep.au
audio/ding.au
audio/return.au
audio/yahoo1.au
audio/yahoo2.au
images/
images/cross.gif
images/not.gif
The JAR tool displays additional information if you use the v option:
jar tvf TicTacToe.jarThe verbose output for the TicTacToe JAR file would look similar to this:
256 Mon Apr 20 10:50:28 PDT 1998 META-INF/MANIFEST.MF
3885 Mon Apr 20 10:49:50 PDT 1998 TicTacToe.class
0 Wed Apr 15 16:39:32 PDT 1998 audio/
4032 Wed Apr 15 16:39:32 PDT 1998 audio/beep.au
2566 Wed Apr 15 16:39:32 PDT 1998 audio/ding.au
6558 Wed Apr 15 16:39:32 PDT 1998 audio/return.au
7834 Wed Apr 15 16:39:32 PDT 1998 audio/yahoo1.au
7463 Wed Apr 15 16:39:32 PDT 1998 audio/yahoo2.au
0 Wed Apr 15 16:39:44 PDT 1998 images/
157 Wed Apr 15 16:39:44 PDT 1998 images/cross.gif
158 Wed Apr 15 16:39:44 PDT 1998 images/not.gif