jdk/src/solaris/doc/sun/man/man1/jar.1
changeset 9573 c02ff5a7c67b
parent 5865 47da38a8c0f0
child 21743 3d979da7bdf0
equal deleted inserted replaced
9572:6f64c69a7574 9573:c02ff5a7c67b
     1 ." Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1 ." Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 ."
     3 ."
     4 ." This code is free software; you can redistribute it and/or modify it
     4 ." This code is free software; you can redistribute it and/or modify it
     5 ." under the terms of the GNU General Public License version 2 only, as
     5 ." under the terms of the GNU General Public License version 2 only, as
     6 ." published by the Free Software Foundation.
     6 ." published by the Free Software Foundation.
    17 ."
    17 ."
    18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19 ." or visit www.oracle.com if you need additional information or have any
    19 ." or visit www.oracle.com if you need additional information or have any
    20 ." questions.
    20 ." questions.
    21 ."
    21 ."
    22 .TH jar 1 "02 Jun 2010"
    22 .TH jar 1 "10 May 2011"
    23 
    23 
    24 .LP
    24 .LP
    25 .SH "Name"
    25 .SH "Name"
    26 jar\-The Java Archive Tool
    26 jar\-The Java Archive Tool
    27 .LP
    27 .LP
    28 \f3jar\fP combines multiple files into a single JAR archive file.   
    28 \f3jar\fP combines multiple files into a single JAR archive file.  
    29 .SH "SYNOPSIS"
    29 .SH "SYNOPSIS"
    30 .LP
       
    31 
       
    32 .LP
    30 .LP
    33 .RS 3
    31 .RS 3
    34 .TP 3
    32 .TP 3
    35 Create jar file 
    33 Create jar file 
    36 \f4jar c\fP\f2[v0Mmfe] [\fP\f2manifest\fP\f2] [\fP\f2jarfile\fP\f2] [\fP\f2entrypoint\fP\f2] [\-C\fP \f2dir\fP\f2]\fP \f2inputfiles\fP \f2[\-J\fP\f2option\fP\f2]\fP 
    34 \f4jar c\fP\f2[v0Mmfe] [\fP\f2manifest\fP\f2] [\fP\f2jarfile\fP\f2] [\fP\f2entrypoint\fP\f2] [\-C\fP \f2dir\fP\f2]\fP \f2inputfiles\fP \f2[\-J\fP\f2option\fP\f2]\fP 
    51 .LP
    49 .LP
    52 .LP
    50 .LP
    53 where:
    51 where:
    54 .LP
    52 .LP
    55 .RS 3
    53 .RS 3
    56 
       
    57 .LP
       
    58 .RS 3
       
    59 .TP 3
    54 .TP 3
    60 cuxtiv0Mmfe 
    55 cuxtiv0Mmfe 
    61 Options that control the \f2jar\fP command. 
    56 Options that control the \f2jar\fP command. 
    62 .TP 3
    57 .TP 3
    63 jarfile 
    58 jarfile 
    78 \-Joption 
    73 \-Joption 
    79 Option to be passed into the Java runtime environment. (There must be no space between \f2\-J\fP and \f2option\fP). 
    74 Option to be passed into the Java runtime environment. (There must be no space between \f2\-J\fP and \f2option\fP). 
    80 .RE
    75 .RE
    81 
    76 
    82 .LP
    77 .LP
    83 .RE
       
    84 .SH "DESCRIPTION"
    78 .SH "DESCRIPTION"
    85 .LP
    79 .LP
    86 
       
    87 .LP
       
    88 The \f3jar\fP tool combines multiple files into a single JAR archive file. \f3jar\fP is a general\-purpose archiving and compression tool, based on ZIP and the 
    80 The \f3jar\fP tool combines multiple files into a single JAR archive file. \f3jar\fP is a general\-purpose archiving and compression tool, based on ZIP and the 
    89 .na
    81 .na
    90 \f2ZLIB\fP @
    82 \f2ZLIB\fP @
    91 .fi
    83 .fi
    92 http://www.gzip.org/zlib/ compression format. However, \f3jar\fP was designed mainly package java applets or applications into a single archive. When the components of an applet or application (files, images and sounds) are combined into a single archive, they can be downloaded by a java agent (like a browser) in a single HTTP transaction, rather than requiring a new connection for each piece. This dramatically improves download times. \f3jar\fP also compresses files and so further improves download time. In addition, it allows individual entries in a file to be signed by the applet author so that their origin can be authenticated. The syntax for the jar tool is almost identical to the syntax for the \f2tar\fP command. A \f3jar\fP archive can be used as a class path entry, whether or not it is compressed. 
    84 http://www.gzip.org/zlib/ compression format. However, \f3jar\fP was designed mainly package java applets or applications into a single archive. When the components of an applet or application (files, images and sounds) are combined into a single archive, they can be downloaded by a java agent (like a browser) in a single HTTP transaction, rather than requiring a new connection for each piece. This dramatically improves download times. \f3jar\fP also compresses files and so further improves download time. In addition, it allows individual entries in a file to be signed by the applet author so that their origin can be authenticated. The syntax for the jar tool is almost identical to the syntax for the \f2tar\fP command. A \f3jar\fP archive can be used as a class path entry, whether or not it is compressed. 
    93 .LP
    85 .LP
    94 Typical usage to combine files into a jar file is:
    86 Typical usage to combine files into a jar file is:
    95 .LP
    87 .LP
    96 .RS 3
       
    97 
       
    98 .LP
       
    99 .nf
    88 .nf
   100 \f3
    89 \f3
   101 .fl
    90 .fl
   102 % jar cf myFile.jar *.class
    91 % jar cf myFile.jar *.class
   103 .fl
    92 .fl
   104 \fP
    93 \fP
   105 .fi
    94 .fi
   106 .RE
       
   107 
    95 
   108 .LP
    96 .LP
   109 In this example, all the class files in the current directory are placed into the file named \f2myFile.jar\fP. The jar tool automatically generates a manifest file entry named \f2META\-INF/MANIFEST.MF\fP. It is always the first entry in the jar file. The manifest file declares meta\-information about the archive, and stores that data as \f2name\ :\ value\fP pairs. Refer to the 
    97 In this example, all the class files in the current directory are placed into the file named \f2myFile.jar\fP. The jar tool automatically generates a manifest file entry named \f2META\-INF/MANIFEST.MF\fP. It is always the first entry in the jar file. The manifest file declares meta\-information about the archive, and stores that data as \f2name\ :\ value\fP pairs. Refer to the 
   110 .na
    98 .na
   111 \f2JAR file specification\fP @
    99 \f2JAR file specification\fP @
   112 .fi
   100 .fi
   113 http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest for details explaining how the jar tool stores meta\-information in the manifest file. 
   101 http://download.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#JAR%20Manifest for details explaining how the jar tool stores meta\-information in the manifest file. 
   114 .LP
   102 .LP
   115 If a jar file should include \f2name\ :\ value\fP pairs contained in an existing manifest file, specify that file using the \f2\-m\fP option:
   103 If a jar file should include \f2name\ :\ value\fP pairs contained in an existing manifest file, specify that file using the \f2\-m\fP option:
   116 .LP
   104 .LP
   117 .RS 3
       
   118 
       
   119 .LP
       
   120 .nf
   105 .nf
   121 \f3
   106 \f3
   122 .fl
   107 .fl
   123 % jar cmf myManifestFile myFile.jar *.class
   108 % jar cmf myManifestFile myFile.jar *.class
   124 .fl
   109 .fl
   125 \fP
   110 \fP
   126 .fi
   111 .fi
   127 .RE
       
   128 
   112 
   129 .LP
   113 .LP
   130 An existing manifest file must end with a new line character.\  \f3jar\fP does not parse the last line of a manifest file if it does not end with a new line character.
   114 An existing manifest file must end with a new line character.\  \f3jar\fP does not parse the last line of a manifest file if it does not end with a new line character.
   131 .br
   115 .br
   132 
   116 
   133 .LP
   117 .LP
   134 .br
   118 .br
   135 
   119 
   136 .LP
   120 .LP
   137 \f3Note:\ \fP A jar command that specifies \f2cfm\fP on the command line instead of \f2cmf\fP (the order of the m and \-f options are reversed), the \f3jar\fP command line must specify the name of the jar archive first, followed by the name of the manifest file: 
   121 \f3Note:\ \fP A jar command that specifies \f2cfm\fP on the command line instead of \f2cmf\fP (the order of the m and \-f options are reversed), the \f3jar\fP command line must specify the name of the jar archive first, followed by the name of the manifest file: 
   138 .RS 3
       
   139 
       
   140 .LP
       
   141 .nf
   122 .nf
   142 \f3
   123 \f3
   143 .fl
   124 .fl
   144 % jar cfm myFile.jar myManifestFile *.class
   125 % jar cfm myFile.jar myManifestFile *.class
   145 .fl
   126 .fl
   146 \fP
   127 \fP
   147 .fi
   128 .fi
   148 .RE
       
   149 
   129 
   150 .LP
   130 .LP
   151 The manifest is in a text format inspired by RFC822 ASCII format, so it is easy to view and process manifest\-file contents. 
   131 The manifest is in a text format inspired by RFC822 ASCII format, so it is easy to view and process manifest\-file contents. 
   152 .LP
   132 .LP
   153 To extract the files from a jar file, use \f2x\fP:
   133 To extract the files from a jar file, use \f2x\fP:
   154 .LP
   134 .LP
   155 .RS 3
       
   156 
       
   157 .LP
       
   158 .nf
   135 .nf
   159 \f3
   136 \f3
   160 .fl
   137 .fl
   161 % jar xf myFile.jar
   138 % jar xf myFile.jar
   162 .fl
   139 .fl
   163 \fP
   140 \fP
   164 .fi
   141 .fi
   165 .RE
       
   166 
   142 
   167 .LP
   143 .LP
   168 .LP
   144 .LP
   169 To extract individual files from a jar file, supply their filenames:
   145 To extract individual files from a jar file, supply their filenames:
   170 .LP
   146 .LP
   171 .RS 3
       
   172 
       
   173 .LP
       
   174 .nf
   147 .nf
   175 \f3
   148 \f3
   176 .fl
   149 .fl
   177 % jar xf myFile.jar foo bar
   150 % jar xf myFile.jar foo bar
   178 .fl
   151 .fl
   179 \fP
   152 \fP
   180 .fi
   153 .fi
   181 .RE
       
   182 
   154 
   183 .LP
   155 .LP
   184 .LP
   156 .LP
   185 Beginning with version 1.3 of the JDK, the \f2jar\fP utility supports 
   157 Beginning with version 1.3 of the JDK, the \f2jar\fP utility supports 
   186 .na
   158 .na
   187 \f2JarIndex\fP @
   159 \f2JarIndex\fP @
   188 .fi
   160 .fi
   189 http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Index, which allows application class loaders to load classes more efficiently from jar files. If an application or applet is bundled into multiple jar files,\  only the necessary jar files will be downloaded and opened to load classes. This performance optimization is enabled by running \f2jar\fP with the \f2\-i\fPoption. It will generate package location information for the specified main jar file and all the jar files it depends on, which need to be specified in the \f2Class\-Path\fP attribute of the main jar file's manifest.
   161 http://download.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#JAR_Index, which allows application class loaders to load classes more efficiently from jar files. If an application or applet is bundled into multiple jar files,\  only the necessary jar files will be downloaded and opened to load classes. This performance optimization is enabled by running \f2jar\fP with the \f2\-i\fPoption. It will generate package location information for the specified main jar file and all the jar files it depends on, which need to be specified in the \f2Class\-Path\fP attribute of the main jar file's manifest.
   190 .LP
       
   191 .RS 3
       
   192 
       
   193 .LP
   162 .LP
   194 .nf
   163 .nf
   195 \f3
   164 \f3
   196 .fl
   165 .fl
   197 % jar i main.jar
   166 % jar i main.jar
   198 .fl
   167 .fl
   199 \fP
   168 \fP
   200 .fi
   169 .fi
   201 .RE
       
   202 
   170 
   203 .LP
   171 .LP
   204 .LP
   172 .LP
   205 In this example, an \f2INDEX.LIST\fP file is inserted into the \f2META\-INF\fP directory of \f2main.jar\fP.
   173 In this example, an \f2INDEX.LIST\fP file is inserted into the \f2META\-INF\fP directory of \f2main.jar\fP.
   206 .br
   174 .br
   208 The application class loader uses the information stored in this file for efficient class loading.\  For details about how location information is stored in the index file, refer to the \f2JarIndex\fP specification.
   176 The application class loader uses the information stored in this file for efficient class loading.\  For details about how location information is stored in the index file, refer to the \f2JarIndex\fP specification.
   209 .br
   177 .br
   210 .br
   178 .br
   211 To copy directories, first compress files in \f2dir1\fP to \f2stdout\fP, then extract from \f2stdin\fP to \f2dir2\fP (omitting the \f2\-f\fP option from both \f2jar\fP commands):
   179 To copy directories, first compress files in \f2dir1\fP to \f2stdout\fP, then extract from \f2stdin\fP to \f2dir2\fP (omitting the \f2\-f\fP option from both \f2jar\fP commands):
   212 .LP
   180 .LP
   213 .RS 3
       
   214 
       
   215 .LP
       
   216 .nf
   181 .nf
   217 \f3
   182 \f3
   218 .fl
   183 .fl
   219 % (cd dir1; jar c .) | (cd dir2; jar x)
   184 % (cd dir1; jar c .) | (cd dir2; jar x)
   220 .fl
   185 .fl
   221 \fP
   186 \fP
   222 .fi
   187 .fi
   223 .RE
       
   224 
   188 
   225 .LP
   189 .LP
   226 .LP
   190 .LP
   227 To review command samples which use \f2jar\fP to opeate on jar files and jar file manifests, see Examples, below. Also refer to the jar trail of the 
   191 To review command samples which use \f2jar\fP to opeate on jar files and jar file manifests, see Examples, below. Also refer to the jar trail of the 
   228 .na
   192 .na
   229 \f2Java Tutorial\fP @
   193 \f2Java Tutorial\fP @
   230 .fi
   194 .fi
   231 http://java.sun.com/docs/books/tutorial/jar.
   195 http://download.oracle.com/javase/tutorial/deployment/jar.
   232 .LP
   196 .LP
   233 .SH "OPTIONS"
   197 .SH "OPTIONS"
   234 .LP
       
   235 
       
   236 .LP
   198 .LP
   237 .RS 3
   199 .RS 3
   238 .TP 3
   200 .TP 3
   239 c 
   201 c 
   240 Creates a new archive file named \f2jarfile\fP (if \f2f\fP is specified) or to standard output (if \f2f\fP and \f2jarfile\fP are omitted). Add to it the files and directories specified by \f2inputfiles\fP. 
   202 Creates a new archive file named \f2jarfile\fP (if \f2f\fP is specified) or to standard output (if \f2f\fP and \f2jarfile\fP are omitted). Add to it the files and directories specified by \f2inputfiles\fP. 
   241 .TP 3
   203 .TP 3
   242 u 
   204 u 
   243 Updates an existing file \f2jarfile\fP (when \f2f\fP is specified) by adding to it files and directories specified by \f2inputfiles\fP. For example: 
   205 Updates an existing file \f2jarfile\fP (when \f2f\fP is specified) by adding to it files and directories specified by \f2inputfiles\fP. For example: 
   244 .RS 3
       
   245 
       
   246 .LP
       
   247 .nf
   206 .nf
   248 \f3
   207 \f3
   249 .fl
   208 .fl
   250 jar uf foo.jar foo.class
   209 jar uf foo.jar foo.class
   251 .fl
   210 .fl
   252 \fP
   211 \fP
   253 .fi
   212 .fi
   254 .RE
       
   255 would add the file \f2foo.class\fP to the existing jar file \f2foo.jar\fP. The \f2\-u\fP option can also update the manifest entry, as given by this example: 
   213 would add the file \f2foo.class\fP to the existing jar file \f2foo.jar\fP. The \f2\-u\fP option can also update the manifest entry, as given by this example: 
   256 .RS 3
       
   257 
       
   258 .LP
       
   259 .nf
   214 .nf
   260 \f3
   215 \f3
   261 .fl
   216 .fl
   262 jar umf manifest foo.jar
   217 jar umf manifest foo.jar
   263 .fl
   218 .fl
   264 \fP
   219 \fP
   265 .fi
   220 .fi
   266 .RE
       
   267 updates the \f2foo.jar\fP manifest with the \f2name : value\fP pairs in \f2manifest\fP. 
   221 updates the \f2foo.jar\fP manifest with the \f2name : value\fP pairs in \f2manifest\fP. 
   268 .TP 3
   222 .TP 3
   269 x 
   223 x 
   270 Extracts files and directories from \f2jarfile\fP (if \f2f\fP is specified) or standard input (if \f2f\fP and \f2jarfile\fP are omitted). If \f2inputfiles\fP is specified, only those specified files and directories are extracted. Otherwise, all files and directories are extracted. The time and date of the extracted files are those given in the archive. 
   224 Extracts files and directories from \f2jarfile\fP (if \f2f\fP is specified) or standard input (if \f2f\fP and \f2jarfile\fP are omitted). If \f2inputfiles\fP is specified, only those specified files and directories are extracted. Otherwise, all files and directories are extracted. The time and date of the extracted files are those given in the archive. 
   271 .TP 3
   225 .TP 3
   272 t 
   226 t 
   273 Lists the table of contents from \f2jarfile\fP (if \f2f\fP is specified) or standard input (if \f2f\fP and \f2jarfile\fP are omitted). If \f2inputfiles\fP is specified, only those specified files and directories are listed. Otherwise, all files and directories are listed. 
   227 Lists the table of contents from \f2jarfile\fP (if \f2f\fP is specified) or standard input (if \f2f\fP and \f2jarfile\fP are omitted). If \f2inputfiles\fP is specified, only those specified files and directories are listed. Otherwise, all files and directories are listed. 
   274 .TP 3
   228 .TP 3
   275 i 
   229 i 
   276 Generate index information for the specified \f2jarfile\fP and its dependent jar files. For example: 
   230 Generate index information for the specified \f2jarfile\fP and its dependent jar files. For example: 
   277 .RS 3
       
   278 
       
   279 .LP
       
   280 .nf
   231 .nf
   281 \f3
   232 \f3
   282 .fl
   233 .fl
   283 jar i foo.jar
   234 jar i foo.jar
   284 .fl
   235 .fl
   285 \fP
   236 \fP
   286 .fi
   237 .fi
   287 .RE
   238 .LP
   288 .LP
   239 would generate an \f2INDEX.LIST\fP file in \f2foo.jar\fP which contains location information for each package in \f2foo.jar\fP and all the jar files specified in the \f2Class\-Path\fP attribute of \f2foo.jar\fP. See the index example.  
   289 would generate an \f2INDEX.LIST\fP file in \f2foo.jar\fP which contains location information for each package in \f2foo.jar\fP and all the jar files specified in the \f2Class\-Path\fP attribute of \f2foo.jar\fP. See the index example.   
       
   290 .TP 3
   240 .TP 3
   291 f 
   241 f 
   292 Specifies the file \f2jarfile\fP to be created (\f2c\fP), updated (\f2u\fP), extracted (\f2x\fP), indexed (\f2i\fP), or viewed (\f2t\fP). The \f2\-f\fP option and filename \f2jarfile\fP are a pair \-\- if present, they must both appear. Omitting \f2f\fP and \f2jarfile\fP accepts a jar file name from \f2stdin\fP(for x and t) or sends jar file to \f2stdout\fP (for c and u). 
   242 Specifies the file \f2jarfile\fP to be created (\f2c\fP), updated (\f2u\fP), extracted (\f2x\fP), indexed (\f2i\fP), or viewed (\f2t\fP). The \f2\-f\fP option and filename \f2jarfile\fP are a pair \-\- if present, they must both appear. Omitting \f2f\fP and \f2jarfile\fP accepts a jar file name from \f2stdin\fP(for x and t) or sends jar file to \f2stdout\fP (for c and u). 
   293 .TP 3
   243 .TP 3
   294 v 
   244 v 
   299 .TP 3
   249 .TP 3
   300 M 
   250 M 
   301 Do not create a manifest file entry (for c and u), or delete a manifest file entry if one exists (for u). 
   251 Do not create a manifest file entry (for c and u), or delete a manifest file entry if one exists (for u). 
   302 .TP 3
   252 .TP 3
   303 m 
   253 m 
   304 Includes \f2name : value\fP attribute pairs from the specified manifest file \f2manifest\fP in the file at \f2META\-INF/MANIFEST.MF\fP. \f2jar\fP adds a \f2name\ :\ value\fP pair unless an entry already exists with the same name, in which case \f2jar\fP updates its value. 
   254 Includes \f2name : value\fP attribute pairs from the specified manifest file \f2manifest\fP in the file at \f2META\-INF/MANIFEST.MF\fP. \f2jar\fP adds a \f2name\ :\ value\fP pair unless an entry already exists with the same name, in which case \f2jar\fP updates its value.
   305 .LP
   255 .br
       
   256 .br
   306 On the command line, the letters \f3m\fP and \f3f\fP must appear in the same order that \f2manifest\fP and \f2jarfile\fP appear. Example use: 
   257 On the command line, the letters \f3m\fP and \f3f\fP must appear in the same order that \f2manifest\fP and \f2jarfile\fP appear. Example use: 
   307 .RS 3
       
   308 
       
   309 .LP
       
   310 .nf
   258 .nf
   311 \f3
   259 \f3
   312 .fl
   260 .fl
   313 jar cmf myManifestFile myFile.jar *.class
   261 jar cmf myManifestFile myFile.jar *.class
   314 .fl
   262 .fl
   315 \fP
   263 \fP
   316 .fi
   264 .fi
   317 .RE
       
   318 You can add special\-purpose \f2name\ :\ value\fP attribute pairs to the manifest that aren't contained in the default manifest. For example, you can add attributes specifying vendor information, version information, package sealing, or to make JAR\-bundled applications executable. See the 
   265 You can add special\-purpose \f2name\ :\ value\fP attribute pairs to the manifest that aren't contained in the default manifest. For example, you can add attributes specifying vendor information, version information, package sealing, or to make JAR\-bundled applications executable. See the 
   319 .na
   266 .na
   320 \f2JAR Files\fP @
   267 \f2JAR Files\fP @
   321 .fi
   268 .fi
   322 http://java.sun.com/docs/books/tutorial/jar/ trail in the Java Tutorial  for examples of using the \f4\-m\fP option. 
   269 http://download.oracle.com/javase/tutorial/deployment/jar/ trail in the Java Tutorial  for examples of using the \f4\-m\fP option. 
   323 .LP
       
   324 .TP 3
   270 .TP 3
   325 e 
   271 e 
   326 Sets \f2entrypoint\fP as the application entry point for stand\-alone applications bundled into executable jar file. The use of this option creates or overrides the \f2Main\-Class\fP attribute value in the manifest file. This option can be used during creation of jar file or while updating the jar file. This option specifies the application entry point without editing or creating the manifest file.
   272 Sets \f2entrypoint\fP as the application entry point for stand\-alone applications bundled into executable jar file. The use of this option creates or overrides the \f2Main\-Class\fP attribute value in the manifest file. This option can be used during creation of jar file or while updating the jar file. This option specifies the application entry point without editing or creating the manifest file.
   327 .br
   273 .br
   328 .br
   274 .br
       
   275 .br
   329 For example, this command creates \f2Main.jar\fP where the \f2Main\-Class\fP attribute value in the manifest is set to \f2Main\fP: 
   276 For example, this command creates \f2Main.jar\fP where the \f2Main\-Class\fP attribute value in the manifest is set to \f2Main\fP: 
   330 .RS 3
       
   331 
       
   332 .LP
       
   333 .nf
   277 .nf
   334 \f3
   278 \f3
   335 .fl
   279 .fl
   336 jar cfe Main.jar Main Main.class
   280 jar cfe Main.jar Main Main.class
   337 .fl
   281 .fl
   338 \fP
   282 \fP
   339 .fi
   283 .fi
   340 .RE
       
   341 .LP
       
   342 The java runtime can directly invoke this application by running the following command: 
   284 The java runtime can directly invoke this application by running the following command: 
   343 .RS 3
       
   344 
       
   345 .LP
       
   346 .nf
   285 .nf
   347 \f3
   286 \f3
   348 .fl
   287 .fl
   349 java \-jar Main.jar
   288 java \-jar Main.jar
   350 .fl
   289 .fl
   351 \fP
   290 \fP
   352 .fi
   291 .fi
   353 .RE
       
   354 If the entrypoint class name is in a package it may use either a dot (".") or slash ("/") character as the delimiter. For example, if \f2Main.class\fP is in a package called \f2foo\fP the entry point can be specified in the following ways: 
   292 If the entrypoint class name is in a package it may use either a dot (".") or slash ("/") character as the delimiter. For example, if \f2Main.class\fP is in a package called \f2foo\fP the entry point can be specified in the following ways: 
   355 .RS 3
       
   356 
       
   357 .LP
       
   358 .nf
   293 .nf
   359 \f3
   294 \f3
   360 .fl
   295 .fl
   361 jar \-cfe Main.jar foo/Main foo/Main.class
   296 jar \-cfe Main.jar foo/Main foo/Main.class
   362 .fl
   297 .fl
   363 \fP
   298 \fP
   364 .fi
   299 .fi
   365 .RE
       
   366 or 
   300 or 
   367 .RS 3
       
   368 
       
   369 .LP
       
   370 .nf
   301 .nf
   371 \f3
   302 \f3
   372 .fl
   303 .fl
   373 jar \-cfe Main.jar foo.Main foo/Main.class
   304 jar \-cfe Main.jar foo.Main foo/Main.class
   374 .fl
   305 .fl
   375 \fP
   306 \fP
   376 .fi
   307 .fi
   377 .RE
   308 \f3Note:\ \fP specifying both \f2\-m\fP and \f2\-e\fP options together when the given manifest also contains the \f2Main\-Class\fP attribute results in an ambigous \f2Main.class\fP specification, leading to an error and the jar creation or update operation is aborted.  
   378 \f3Note:\ \fP specifying both \f2\-m\fP and \f2\-e\fP options together when the given manifest also contains the \f2Main\-Class\fP attribute results in an ambigous \f2Main.class\fP specification, leading to an error and the jar creation or update operation is aborted. 
   309 .TP 3
   379 .LP
   310 \-C\ dir 
   380 .TP 3
       
   381 \-C \ dir 
       
   382 Temporarily changes directories (\f2cd\fP\ \f2dir\fP) during execution of the \f2jar\fP command while processing the following \f2inputfiles\fP argument. Its operation is intended to be similar to the \f2\-C\fP option of the UNIX \f2tar\fP utility.
   311 Temporarily changes directories (\f2cd\fP\ \f2dir\fP) during execution of the \f2jar\fP command while processing the following \f2inputfiles\fP argument. Its operation is intended to be similar to the \f2\-C\fP option of the UNIX \f2tar\fP utility.
   383 .br
   312 .br
   384 .br
   313 .br
   385 For example, this command changes to the \f2classes\fP directory and adds the \f2bar.class\fP from that directory to \f2foo.jar\fP: 
   314 For example, this command changes to the \f2classes\fP directory and adds the \f2bar.class\fP from that directory to \f2foo.jar\fP: 
   386 .RS 3
       
   387 
       
   388 .LP
       
   389 .nf
   315 .nf
   390 \f3
   316 \f3
   391 .fl
   317 .fl
   392 jar uf foo.jar \-C classes bar.class
   318 jar uf foo.jar \-C classes bar.class
   393 .fl
   319 .fl
   394 \fP
   320 \fP
   395 .fi
   321 .fi
   396 .RE
       
   397 This command changes to the \f2classes\fP directory and adds to \f2foo.jar\fP all files within the \f2classes\fP directory (without creating a classes directory in the jar file), then changes back to the original directory before changing to the \f2bin\fP directory to add \f2xyz.class\fP to \f2foo.jar\fP. 
   322 This command changes to the \f2classes\fP directory and adds to \f2foo.jar\fP all files within the \f2classes\fP directory (without creating a classes directory in the jar file), then changes back to the original directory before changing to the \f2bin\fP directory to add \f2xyz.class\fP to \f2foo.jar\fP. 
   398 .RS 3
       
   399 
       
   400 .LP
       
   401 .nf
   323 .nf
   402 \f3
   324 \f3
   403 .fl
   325 .fl
   404 jar uf foo.jar \-C classes . \-C bin xyz.class
   326 jar uf foo.jar \-C classes . \-C bin xyz.class
   405 .fl
   327 .fl
   406 \fP
   328 \fP
   407 .fi
   329 .fi
   408 .RE
       
   409 If \f2classes\fP holds files \f2bar1\fP and \f2bar2\fP, then here's what the jar file will contain using \f2jar tf foo.jar\fP: 
   330 If \f2classes\fP holds files \f2bar1\fP and \f2bar2\fP, then here's what the jar file will contain using \f2jar tf foo.jar\fP: 
   410 .RS 3
       
   411 
       
   412 .LP
       
   413 .nf
   331 .nf
   414 \f3
   332 \f3
   415 .fl
   333 .fl
   416 META\-INF/
   334 META\-INF/
   417 .fl
   335 .fl
   423 .fl
   341 .fl
   424 xyz.class
   342 xyz.class
   425 .fl
   343 .fl
   426 \fP
   344 \fP
   427 .fi
   345 .fi
   428 .RE
       
   429 .LP
   346 .LP
   430 .TP 3
   347 .TP 3
   431 \-Joption 
   348 \-Joption 
   432 Pass \f2option\fP to the Java runtime environment, where \f2option\fP is one of the options described on the reference page for the java application launcher. For example, \f4\-J\-Xmx48M\fP sets the maximum memory to 48 megabytes. It is a common convention for \f2\-J\fP to pass options to the underlying runtime environment. 
   349 Pass \f2option\fP to the Java runtime environment, where \f2option\fP is one of the options described on the reference page for the java application launcher. For example, \f4\-J\-Xmx48M\fP sets the maximum memory to 48 megabytes. It is a common convention for \f2\-J\fP to pass options to the underlying runtime environment. 
   433 .RE
   350 .RE
   434 
   351 
   435 .LP
   352 .LP
   436 .SH "COMMAND LINE ARGUMENT FILES"
   353 .SH "COMMAND LINE ARGUMENT FILES"
   437 .LP
   354 .LP
   438 
       
   439 .LP
       
   440 To shorten or simplify the jar command line, you can specify one or more files that themselves contain arguments to the \f2jar\fP command (except \f2\-J\fP options). This enables you to create jar commands of any length, overcoming command line limits imposed by the operating system. 
   355 To shorten or simplify the jar command line, you can specify one or more files that themselves contain arguments to the \f2jar\fP command (except \f2\-J\fP options). This enables you to create jar commands of any length, overcoming command line limits imposed by the operating system. 
   441 .LP
   356 .LP
   442 An argument file can include options and filenames. The arguments within a file can be space\-separated or newline\-separated. Filenames within an argument file are relative to the current directory, not relative to the location of the argument file. Wildcards (*) that might otherwise be expanded by the operating system shell are not expanded. Use of the \f2@\fP character to recursively interpret files is not supported. The \f2\-J\fP options are not supported because they are passed to the launcher, which does not support argument files.
   357 An argument file can include options and filenames. The arguments within a file can be space\-separated or newline\-separated. Filenames within an argument file are relative to the current directory, not relative to the location of the argument file. Wildcards (*) that might otherwise be expanded by the operating system shell are not expanded. Use of the \f2@\fP character to recursively interpret files is not supported. The \f2\-J\fP options are not supported because they are passed to the launcher, which does not support argument files.
   443 .LP
   358 .LP
   444 .LP
   359 .LP
   445 When executing \f2jar\fP, pass in the path and name of each argument file with the \f2@\fP leading character. When \f2jar\fP encounters an argument beginning with the character \f2@\fP, it expands the contents of that file into the argument list.
   360 When executing \f2jar\fP, pass in the path and name of each argument file with the \f2@\fP leading character. When \f2jar\fP encounters an argument beginning with the character \f2@\fP, it expands the contents of that file into the argument list.
   446 .br
   361 .br
   447 .br
   362 .br
   448 The example below, \f2classes.list\fP holds the names of files output by a \f2find\fP command: 
   363 The example below, \f2classes.list\fP holds the names of files output by a \f2find\fP command: 
   449 .LP
   364 .LP
   450 .RS 3
       
   451 
       
   452 .LP
       
   453 .nf
   365 .nf
   454 \f3
   366 \f3
   455 .fl
   367 .fl
   456 % find \fP\f3.\fP \-name '*.class' \-print > classes.list
   368 % find \fP\f3.\fP \-name '*.class' \-print > classes.list
   457 .fl
   369 .fl
   458 .fi
   370 .fi
   459 .RE
       
   460 
   371 
   461 .LP
   372 .LP
   462 .LP
   373 .LP
   463 You can then execute the \f2jar\fP command on \f2Classes.list\fP by passing it to \f2jar\fP using argfile syntax:
   374 You can then execute the \f2jar\fP command on \f2Classes.list\fP by passing it to \f2jar\fP using argfile syntax:
   464 .LP
   375 .LP
   465 .RS 3
       
   466 
       
   467 .LP
       
   468 .nf
   376 .nf
   469 \f3
   377 \f3
   470 .fl
   378 .fl
   471 % jar cf my.jar @classes.list
   379 % jar cf my.jar @classes.list
   472 .fl
   380 .fl
   473 \fP
   381 \fP
   474 .fi
   382 .fi
   475 .RE
       
   476 
   383 
   477 .LP
   384 .LP
   478 An argument file can specify a path, but any filenames inside the argument file that have relative paths are relative to the current working directory, not to the path passed in. Here is an example: 
   385 An argument file can specify a path, but any filenames inside the argument file that have relative paths are relative to the current working directory, not to the path passed in. Here is an example: 
   479 .RS 3
       
   480 
       
   481 .LP
       
   482 .nf
   386 .nf
   483 \f3
   387 \f3
   484 .fl
   388 .fl
   485 % jar @path1/classes.list
   389 % jar @path1/classes.list
   486 .fl
   390 .fl
   487 \fP
   391 \fP
   488 .fi
   392 .fi
   489 .RE
       
   490 
   393 
   491 .LP
   394 .LP
   492 .LP
   395 .LP
   493 
   396 
   494 .LP
   397 .LP
   495 .SH "EXAMPLES"
   398 .SH "EXAMPLES"
   496 .LP
   399 .LP
   497 
       
   498 .LP
       
   499 To add all the files in a particular directory to an archive (overwriting contents if the archive already exists). Enumerating verbosely (with the \f2\-v\fP option) will tell you more information about the files in the archive, such as their size and last modified date. 
   400 To add all the files in a particular directory to an archive (overwriting contents if the archive already exists). Enumerating verbosely (with the \f2\-v\fP option) will tell you more information about the files in the archive, such as their size and last modified date. 
   500 .RS 3
       
   501 
       
   502 .LP
       
   503 .nf
   401 .nf
   504 \f3
   402 \f3
   505 .fl
   403 .fl
   506 % ls
   404 % ls
   507 .fl
   405 .fl
   533 .fl
   431 .fl
   534 adding: spacemusic.au(in = 3079) (out= 73)(deflated 97%)
   432 adding: spacemusic.au(in = 3079) (out= 73)(deflated 97%)
   535 .fl
   433 .fl
   536 \fP
   434 \fP
   537 .fi
   435 .fi
   538 .RE
       
   539 
   436 
   540 .LP
   437 .LP
   541 If you already have separate subdirectories for images, audio files and classes, you can combine them into a single jar file: 
   438 If you already have separate subdirectories for images, audio files and classes, you can combine them into a single jar file: 
   542 .RS 3
       
   543 
       
   544 .LP
       
   545 .nf
   439 .nf
   546 \f3
   440 \f3
   547 .fl
   441 .fl
   548 % ls \-F
   442 % ls \-F
   549 .fl
   443 .fl
   583 .fl
   477 .fl
   584 audio/ bundle.jar classes/ images/
   478 audio/ bundle.jar classes/ images/
   585 .fl
   479 .fl
   586 \fP
   480 \fP
   587 .fi
   481 .fi
   588 .RE
       
   589 
   482 
   590 .LP
   483 .LP
   591 To see the entry names in the jarfile, use the \f2t\fP option: 
   484 To see the entry names in the jarfile, use the \f2t\fP option: 
   592 .RS 3
       
   593 
       
   594 .LP
       
   595 .nf
   485 .nf
   596 \f3
   486 \f3
   597 .fl
   487 .fl
   598 % jar tf bundle.jar
   488 % jar tf bundle.jar
   599 .fl
   489 .fl
   617 .fl
   507 .fl
   618 images/at_work.gif
   508 images/at_work.gif
   619 .fl
   509 .fl
   620 \fP
   510 \fP
   621 .fi
   511 .fi
   622 .RE
       
   623 
   512 
   624 .LP
   513 .LP
   625 .LP
   514 .LP
   626 To add an index file to the jar file for speeding up class loading, use the \f2i\fP option.
   515 To add an index file to the jar file for speeding up class loading, use the \f2i\fP option.
   627 .br
   516 .br
   628 .br
   517 .br
   629 Example:
   518 Example:
   630 .br
   519 .br
   631 
   520 
   632 .LP
   521 .LP
   633 .RS 3
       
   634 
       
   635 .LP
       
   636 If you split the inter\-dependent classes for a stock trade application into three jar files: \f2main.jar\fP, \f2buy.jar\fP, and \f2sell.jar\fP.
   522 If you split the inter\-dependent classes for a stock trade application into three jar files: \f2main.jar\fP, \f2buy.jar\fP, and \f2sell.jar\fP.
   637 .br
   523 .br
   638 
   524 
   639 .LP
   525 .LP
   640 .br
   526 .br
   658 .fl
   544 .fl
   659 \fP
   545 \fP
   660 .fi
   546 .fi
   661 
   547 
   662 .LP
   548 .LP
   663 An \f2INDEX.LIST\fP file is inserted to the \f2META\-INF\fP directory. This enables the application class loader to download the specified jar files when it is searching for classes or resources.
   549 An \f2INDEX.LIST\fP file is inserted to the \f2META\-INF\fP directory. This enables the application class loader to download the specified jar files when it is searching for classes or resources.  
   664 .RE
       
   665 .SH "SEE ALSO"
   550 .SH "SEE ALSO"
   666 .LP
   551 .LP
   667 
       
   668 .LP
   552 .LP
   669 .na
   553 .na
   670 \f2The Jar Overview\fP @
   554 \f2The Jar Overview\fP @
   671 .fi
   555 .fi
   672 http://java.sun.com/javase/6/docs/technotes/guides/jar/jarGuide.html
   556 http://download.oracle.com/javase/7/docs/technotes/guides/jar/jarGuide.html
   673 .br
   557 .LP
   674 
       
   675 .LP
   558 .LP
   676 .na
   559 .na
   677 \f2The Jar File Specification\fP @
   560 \f2The Jar File Specification\fP @
   678 .fi
   561 .fi
   679 http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
   562 http://download.oracle.com/javase/7/docs/technotes/guides/jar/jar.html
   680 .br
   563 .LP
   681 
       
   682 .LP
   564 .LP
   683 .na
   565 .na
   684 \f2The JarIndex Spec\fP @
   566 \f2The JarIndex Spec\fP @
   685 .fi
   567 .fi
   686 http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Index
   568 http://download.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#JAR_Index
   687 .br
   569 .LP
   688 
       
   689 .LP
   570 .LP
   690 .na
   571 .na
   691 \f2Jar Tutorial\fP @
   572 \f2Jar Tutorial\fP @
   692 .fi
   573 .fi
   693 http://java.sun.com/docs/books/tutorial/jar on the Java Software web site.
   574 http://download.oracle.com/javase/tutorial/deployment/jar/index.html
   694 .br
   575 .LP
   695 
   576 .LP
   696 .LP
   577 pack200(1)
   697 pack200(1)  
   578 .LP
       
   579