12.4 Combining Backup and Compression
12.4.1 The jar command
The jar (java archive) command is similar to the tar command, but compresses the resulting file in the same step. It is a Java™ application that combines multiple files into a single jar (Java archive) file. It is also a general purpose archiving and compression tool, based on ZIP and the ZLIB compression format. The jar command was originally created for Java programmers to download multiple files with one request, rather than having to issue a download request for each separate file. The jar command is standard with the Solaris operating system, but is available on any system that has Java virtual machine (JVM) installed. The syntax for the jar tool is almost identical to the syntax for the tar command. Figure shows the options available with the jar command.

It is not necessary to use a hyphen (-) before options when issuing the jar command. Figure provides an example of the use of the jar command to archive and compress all directories and files in the /home/user2 directory.

Interactive Media Activity (Flash, 95 kB)
  Archiving and Compressing Files with jar

In this media activity, you are logged in as user2 and your current working directory is: /home/user2. Refer to the Class File Tree Structure by clicking the 'tree' button located on the Menu Bar and type the commands that would accomplish the requested objectives.
Note: Be sure to press enter after each one. Click on step 1 to begin.

Lab Activity (Adobe Acrobat Reader, 63 kB)
  Command Line Archive Tools

In this lab, you will work with the Tape Archive (tar) and Java Archive (jar) utilities to perform backups of data as well as restoring data from backups. We will cover the UNIX file compression utility and you will use tar and compress to back up and restore your home directory.