5865
|
1 |
." Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
2
|
2 |
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
."
|
|
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
|
|
6 |
." published by the Free Software Foundation.
|
|
7 |
."
|
|
8 |
." This code is distributed in the hope that it will be useful, but WITHOUT
|
|
9 |
." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
10 |
." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
11 |
." version 2 for more details (a copy is included in the LICENSE file that
|
|
12 |
." accompanied this code).
|
|
13 |
."
|
|
14 |
." You should have received a copy of the GNU General Public License version
|
|
15 |
." 2 along with this work; if not, write to the Free Software Foundation,
|
|
16 |
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
17 |
."
|
5506
|
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
|
|
20 |
." questions.
|
2
|
21 |
."
|
5865
|
22 |
.TH jar 1 "02 Jun 2010"
|
2692
|
23 |
|
2
|
24 |
.LP
|
2692
|
25 |
.SH "Name"
|
2
|
26 |
jar\-The Java Archive Tool
|
|
27 |
.LP
|
|
28 |
\f3jar\fP combines multiple files into a single JAR archive file.
|
|
29 |
.SH "SYNOPSIS"
|
|
30 |
.LP
|
|
31 |
|
|
32 |
.LP
|
2692
|
33 |
.RS 3
|
2
|
34 |
.TP 3
|
|
35 |
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
|
|
37 |
.TP 3
|
|
38 |
Update jar file
|
|
39 |
\f4jar u\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
|
|
40 |
.TP 3
|
|
41 |
Extract jar file
|
|
42 |
\f4jar x\fP\f2[vf] [\fP\f2jarfile\fP\f2] [\fP\f2inputfiles\fP\f2] [\-J\fP\f2option\fP\f2]\fP
|
|
43 |
.TP 3
|
|
44 |
List table of contents of jar file
|
|
45 |
\f4jar t\fP\f2[vf] [\fP\f2jarfile\fP\f2] [\fP\f2inputfiles\fP\f2] [\-J\fP\f2option\fP\f2]\fP
|
|
46 |
.TP 3
|
|
47 |
Add index to jar file
|
|
48 |
\f4jar i\fP \f2jarfile\fP \f2[\-J\fP\f2option\fP\f2]\fP
|
2692
|
49 |
.RE
|
|
50 |
|
2
|
51 |
.LP
|
|
52 |
.LP
|
|
53 |
where:
|
|
54 |
.LP
|
|
55 |
.RS 3
|
|
56 |
|
|
57 |
.LP
|
2692
|
58 |
.RS 3
|
2
|
59 |
.TP 3
|
|
60 |
cuxtiv0Mmfe
|
|
61 |
Options that control the \f2jar\fP command.
|
|
62 |
.TP 3
|
2692
|
63 |
jarfile
|
2
|
64 |
Jar file to be created (\f2c\fP), updated (\f2u\fP), extracted (\f2x\fP), or have its table of contents viewed (\f2t\fP). The \f2\-f\fP option and filename \f2jarfile\fP are a pair \-\- if either is present, they must both appear. Note that omitting \f2f\fP and \f2jarfile\fP accepts a "jar file" from standard input (for x and t) or sends the "jar file" to standard output (for c and u).
|
|
65 |
.TP 3
|
|
66 |
inputfiles
|
|
67 |
Files or directories, separated by spaces, to be combined into \f2jarfile\fP (for c and u), or to be extracted (for x) or listed (for t) from \f2jarfile\fP. All directories are processed recursively. The files are compressed unless option \f20\fP (zero) is used.
|
|
68 |
.TP 3
|
2692
|
69 |
manifest
|
2
|
70 |
Pre\-existing manifest file whose \f2name\fP\f2:\fP \f2value\fP pairs are to be included in MANIFEST.MF in the jar file. The \f2\-m\fP option and filename \f2manifest\fP are a pair \-\- if either is present, they must both appear. The letters \f3m\fP, \f3f\fP and \f3e\fP must appear in the same order that \f2manifest\fP, \f2jarfile\fP, \f2entrypoint\fP appear.
|
|
71 |
.TP 3
|
|
72 |
entrypoint
|
|
73 |
The name of the class that set as the application entry point for stand\-alone applications bundled into executable jar file. The \f2\-e\fP option and entrypoint are a pair \-\- if either is present, they must both appear. The letters \f3m\fP, \f3f\fP and \f3e\fP must appear in the same order that \f2manifest\fP, \f2jarfile\fP, \f2entrypoint\fP appear.
|
|
74 |
.TP 3
|
|
75 |
\-C\ dir
|
|
76 |
Temporarily changes directories to \f2dir\fP while processing the following \f2inputfiles\fP argument. Multiple \f2\-C\ \fP\f2dir\fP \f2inputfiles\fP sets are allowed.
|
|
77 |
.TP 3
|
|
78 |
\-Joption
|
|
79 |
Option to be passed into the Java runtime environment. (There must be no space between \f2\-J\fP and \f2option\fP).
|
2692
|
80 |
.RE
|
|
81 |
|
2
|
82 |
.LP
|
|
83 |
.RE
|
|
84 |
.SH "DESCRIPTION"
|
|
85 |
.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
|
|
89 |
.na
|
|
90 |
\f2ZLIB\fP @
|
|
91 |
.fi
|
2692
|
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.
|
2
|
93 |
.LP
|
|
94 |
Typical usage to combine files into a jar file is:
|
|
95 |
.LP
|
|
96 |
.RS 3
|
|
97 |
|
|
98 |
.LP
|
|
99 |
.nf
|
|
100 |
\f3
|
|
101 |
.fl
|
|
102 |
% jar cf myFile.jar *.class
|
|
103 |
.fl
|
|
104 |
\fP
|
|
105 |
.fi
|
|
106 |
.RE
|
|
107 |
|
|
108 |
.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
|
|
110 |
.na
|
|
111 |
\f2JAR file specification\fP @
|
|
112 |
.fi
|
2692
|
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.
|
2
|
114 |
.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:
|
|
116 |
.LP
|
|
117 |
.RS 3
|
|
118 |
|
|
119 |
.LP
|
|
120 |
.nf
|
|
121 |
\f3
|
|
122 |
.fl
|
|
123 |
% jar cmf myManifestFile myFile.jar *.class
|
|
124 |
.fl
|
|
125 |
\fP
|
|
126 |
.fi
|
|
127 |
.RE
|
|
128 |
|
|
129 |
.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.
|
|
131 |
.br
|
|
132 |
|
|
133 |
.LP
|
|
134 |
.br
|
|
135 |
|
|
136 |
.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:
|
|
138 |
.RS 3
|
|
139 |
|
|
140 |
.LP
|
|
141 |
.nf
|
|
142 |
\f3
|
|
143 |
.fl
|
|
144 |
% jar cfm myFile.jar myManifestFile *.class
|
|
145 |
.fl
|
|
146 |
\fP
|
|
147 |
.fi
|
|
148 |
.RE
|
|
149 |
|
|
150 |
.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.
|
|
152 |
.LP
|
|
153 |
To extract the files from a jar file, use \f2x\fP:
|
|
154 |
.LP
|
|
155 |
.RS 3
|
|
156 |
|
|
157 |
.LP
|
|
158 |
.nf
|
|
159 |
\f3
|
|
160 |
.fl
|
|
161 |
% jar xf myFile.jar
|
|
162 |
.fl
|
|
163 |
\fP
|
|
164 |
.fi
|
|
165 |
.RE
|
|
166 |
|
|
167 |
.LP
|
|
168 |
.LP
|
|
169 |
To extract individual files from a jar file, supply their filenames:
|
|
170 |
.LP
|
|
171 |
.RS 3
|
|
172 |
|
|
173 |
.LP
|
|
174 |
.nf
|
|
175 |
\f3
|
|
176 |
.fl
|
|
177 |
% jar xf myFile.jar foo bar
|
|
178 |
.fl
|
|
179 |
\fP
|
|
180 |
.fi
|
|
181 |
.RE
|
|
182 |
|
|
183 |
.LP
|
|
184 |
.LP
|
5865
|
185 |
Beginning with version 1.3 of the JDK, the \f2jar\fP utility supports
|
2
|
186 |
.na
|
|
187 |
\f2JarIndex\fP @
|
|
188 |
.fi
|
2692
|
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.
|
2
|
190 |
.LP
|
|
191 |
.RS 3
|
|
192 |
|
|
193 |
.LP
|
|
194 |
.nf
|
|
195 |
\f3
|
|
196 |
.fl
|
|
197 |
% jar i main.jar
|
|
198 |
.fl
|
|
199 |
\fP
|
|
200 |
.fi
|
|
201 |
.RE
|
|
202 |
|
|
203 |
.LP
|
|
204 |
.LP
|
|
205 |
In this example, an \f2INDEX.LIST\fP file is inserted into the \f2META\-INF\fP directory of \f2main.jar\fP.
|
|
206 |
.br
|
|
207 |
.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.
|
|
209 |
.br
|
|
210 |
.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):
|
|
212 |
.LP
|
|
213 |
.RS 3
|
|
214 |
|
|
215 |
.LP
|
|
216 |
.nf
|
|
217 |
\f3
|
|
218 |
.fl
|
|
219 |
% (cd dir1; jar c .) | (cd dir2; jar x)
|
|
220 |
.fl
|
|
221 |
\fP
|
|
222 |
.fi
|
|
223 |
.RE
|
|
224 |
|
|
225 |
.LP
|
|
226 |
.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
|
|
228 |
.na
|
|
229 |
\f2Java Tutorial\fP @
|
|
230 |
.fi
|
|
231 |
http://java.sun.com/docs/books/tutorial/jar.
|
|
232 |
.LP
|
|
233 |
.SH "OPTIONS"
|
|
234 |
.LP
|
|
235 |
|
|
236 |
.LP
|
2692
|
237 |
.RS 3
|
2
|
238 |
.TP 3
|
|
239 |
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.
|
|
241 |
.TP 3
|
|
242 |
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:
|
|
244 |
.RS 3
|
|
245 |
|
|
246 |
.LP
|
|
247 |
.nf
|
|
248 |
\f3
|
|
249 |
.fl
|
|
250 |
jar uf foo.jar foo.class
|
|
251 |
.fl
|
|
252 |
\fP
|
|
253 |
.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:
|
|
256 |
.RS 3
|
|
257 |
|
|
258 |
.LP
|
|
259 |
.nf
|
|
260 |
\f3
|
|
261 |
.fl
|
|
262 |
jar umf manifest foo.jar
|
|
263 |
.fl
|
|
264 |
\fP
|
|
265 |
.fi
|
|
266 |
.RE
|
|
267 |
updates the \f2foo.jar\fP manifest with the \f2name : value\fP pairs in \f2manifest\fP.
|
|
268 |
.TP 3
|
|
269 |
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.
|
|
271 |
.TP 3
|
|
272 |
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.
|
|
274 |
.TP 3
|
|
275 |
i
|
|
276 |
Generate index information for the specified \f2jarfile\fP and its dependent jar files. For example:
|
|
277 |
.RS 3
|
|
278 |
|
|
279 |
.LP
|
|
280 |
.nf
|
|
281 |
\f3
|
|
282 |
.fl
|
|
283 |
jar i foo.jar
|
|
284 |
.fl
|
|
285 |
\fP
|
|
286 |
.fi
|
|
287 |
.RE
|
|
288 |
.LP
|
|
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
|
|
291 |
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).
|
|
293 |
.TP 3
|
|
294 |
v
|
|
295 |
Generates verbose output to standard output. Examples shown below.
|
|
296 |
.TP 3
|
|
297 |
0
|
|
298 |
(zero) Store without using ZIP compression.
|
|
299 |
.TP 3
|
|
300 |
M
|
|
301 |
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
|
|
303 |
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.
|
|
305 |
.LP
|
|
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:
|
|
307 |
.RS 3
|
|
308 |
|
|
309 |
.LP
|
|
310 |
.nf
|
|
311 |
\f3
|
|
312 |
.fl
|
|
313 |
jar cmf myManifestFile myFile.jar *.class
|
|
314 |
.fl
|
|
315 |
\fP
|
|
316 |
.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
|
|
319 |
.na
|
|
320 |
\f2JAR Files\fP @
|
|
321 |
.fi
|
|
322 |
http://java.sun.com/docs/books/tutorial/jar/ trail in the Java Tutorial for examples of using the \f4\-m\fP option.
|
2692
|
323 |
.LP
|
2
|
324 |
.TP 3
|
|
325 |
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.
|
|
327 |
.br
|
|
328 |
.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:
|
|
330 |
.RS 3
|
|
331 |
|
|
332 |
.LP
|
|
333 |
.nf
|
|
334 |
\f3
|
|
335 |
.fl
|
|
336 |
jar cfe Main.jar Main Main.class
|
|
337 |
.fl
|
|
338 |
\fP
|
|
339 |
.fi
|
|
340 |
.RE
|
|
341 |
.LP
|
|
342 |
The java runtime can directly invoke this application by running the following command:
|
|
343 |
.RS 3
|
|
344 |
|
|
345 |
.LP
|
|
346 |
.nf
|
|
347 |
\f3
|
|
348 |
.fl
|
|
349 |
java \-jar Main.jar
|
|
350 |
.fl
|
|
351 |
\fP
|
|
352 |
.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:
|
|
355 |
.RS 3
|
|
356 |
|
|
357 |
.LP
|
|
358 |
.nf
|
|
359 |
\f3
|
|
360 |
.fl
|
|
361 |
jar \-cfe Main.jar foo/Main foo/Main.class
|
|
362 |
.fl
|
|
363 |
\fP
|
|
364 |
.fi
|
|
365 |
.RE
|
|
366 |
or
|
|
367 |
.RS 3
|
|
368 |
|
|
369 |
.LP
|
|
370 |
.nf
|
|
371 |
\f3
|
|
372 |
.fl
|
|
373 |
jar \-cfe Main.jar foo.Main foo/Main.class
|
|
374 |
.fl
|
|
375 |
\fP
|
|
376 |
.fi
|
|
377 |
.RE
|
|
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.
|
|
379 |
.LP
|
|
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.
|
|
383 |
.br
|
|
384 |
.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:
|
|
386 |
.RS 3
|
|
387 |
|
|
388 |
.LP
|
|
389 |
.nf
|
|
390 |
\f3
|
|
391 |
.fl
|
|
392 |
jar uf foo.jar \-C classes bar.class
|
|
393 |
.fl
|
|
394 |
\fP
|
|
395 |
.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.
|
|
398 |
.RS 3
|
|
399 |
|
|
400 |
.LP
|
|
401 |
.nf
|
|
402 |
\f3
|
|
403 |
.fl
|
|
404 |
jar uf foo.jar \-C classes . \-C bin xyz.class
|
|
405 |
.fl
|
|
406 |
\fP
|
|
407 |
.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:
|
|
410 |
.RS 3
|
|
411 |
|
|
412 |
.LP
|
|
413 |
.nf
|
|
414 |
\f3
|
|
415 |
.fl
|
|
416 |
META\-INF/
|
|
417 |
.fl
|
|
418 |
META\-INF/MANIFEST.MF
|
|
419 |
.fl
|
|
420 |
bar1
|
|
421 |
.fl
|
|
422 |
bar2
|
|
423 |
.fl
|
|
424 |
xyz.class
|
|
425 |
.fl
|
|
426 |
\fP
|
|
427 |
.fi
|
|
428 |
.RE
|
|
429 |
.LP
|
|
430 |
.TP 3
|
|
431 |
\-Joption
|
2692
|
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.
|
|
433 |
.RE
|
|
434 |
|
2
|
435 |
.LP
|
|
436 |
.SH "COMMAND LINE ARGUMENT FILES"
|
|
437 |
.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.
|
|
441 |
.LP
|
2692
|
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.
|
2
|
443 |
.LP
|
|
444 |
.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.
|
|
446 |
.br
|
|
447 |
.br
|
|
448 |
The example below, \f2classes.list\fP holds the names of files output by a \f2find\fP command:
|
|
449 |
.LP
|
|
450 |
.RS 3
|
|
451 |
|
|
452 |
.LP
|
|
453 |
.nf
|
|
454 |
\f3
|
|
455 |
.fl
|
|
456 |
% find \fP\f3.\fP \-name '*.class' \-print > classes.list
|
|
457 |
.fl
|
|
458 |
.fi
|
|
459 |
.RE
|
|
460 |
|
|
461 |
.LP
|
|
462 |
.LP
|
|
463 |
You can then execute the \f2jar\fP command on \f2Classes.list\fP by passing it to \f2jar\fP using argfile syntax:
|
|
464 |
.LP
|
|
465 |
.RS 3
|
|
466 |
|
|
467 |
.LP
|
|
468 |
.nf
|
|
469 |
\f3
|
|
470 |
.fl
|
|
471 |
% jar cf my.jar @classes.list
|
|
472 |
.fl
|
|
473 |
\fP
|
|
474 |
.fi
|
|
475 |
.RE
|
|
476 |
|
|
477 |
.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:
|
|
479 |
.RS 3
|
|
480 |
|
|
481 |
.LP
|
|
482 |
.nf
|
|
483 |
\f3
|
|
484 |
.fl
|
|
485 |
% jar @path1/classes.list
|
|
486 |
.fl
|
|
487 |
\fP
|
|
488 |
.fi
|
|
489 |
.RE
|
|
490 |
|
|
491 |
.LP
|
|
492 |
.LP
|
|
493 |
|
|
494 |
.LP
|
|
495 |
.SH "EXAMPLES"
|
|
496 |
.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.
|
|
500 |
.RS 3
|
|
501 |
|
|
502 |
.LP
|
|
503 |
.nf
|
|
504 |
\f3
|
|
505 |
.fl
|
|
506 |
% ls
|
|
507 |
.fl
|
|
508 |
1.au Animator.class monkey.jpg
|
|
509 |
.fl
|
|
510 |
2.au Wave.class spacemusic.au
|
|
511 |
.fl
|
|
512 |
3.au at_work.gif
|
|
513 |
.fl
|
|
514 |
|
|
515 |
.fl
|
|
516 |
% jar cvf bundle.jar *
|
|
517 |
.fl
|
|
518 |
added manifest
|
|
519 |
.fl
|
|
520 |
adding: 1.au(in = 2324) (out= 67)(deflated 97%)
|
|
521 |
.fl
|
|
522 |
adding: 2.au(in = 6970) (out= 90)(deflated 98%)
|
|
523 |
.fl
|
|
524 |
adding: 3.au(in = 11616) (out= 108)(deflated 99%)
|
|
525 |
.fl
|
|
526 |
adding: Animator.class(in = 2266) (out= 66)(deflated 97%)
|
|
527 |
.fl
|
|
528 |
adding: Wave.class(in = 3778) (out= 81)(deflated 97%)
|
|
529 |
.fl
|
|
530 |
adding: at_work.gif(in = 6621) (out= 89)(deflated 98%)
|
|
531 |
.fl
|
|
532 |
adding: monkey.jpg(in = 7667) (out= 91)(deflated 98%)
|
|
533 |
.fl
|
|
534 |
adding: spacemusic.au(in = 3079) (out= 73)(deflated 97%)
|
|
535 |
.fl
|
|
536 |
\fP
|
|
537 |
.fi
|
|
538 |
.RE
|
|
539 |
|
|
540 |
.LP
|
|
541 |
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
|
|
546 |
\f3
|
|
547 |
.fl
|
|
548 |
% ls \-F
|
|
549 |
.fl
|
|
550 |
audio/ classes/ images/
|
|
551 |
.fl
|
|
552 |
|
|
553 |
.fl
|
|
554 |
% jar cvf bundle.jar audio classes images
|
|
555 |
.fl
|
|
556 |
added manifest
|
|
557 |
.fl
|
|
558 |
adding: audio/(in = 0) (out= 0)(stored 0%)
|
|
559 |
.fl
|
|
560 |
adding: audio/1.au(in = 2324) (out= 67)(deflated 97%)
|
|
561 |
.fl
|
|
562 |
adding: audio/2.au(in = 6970) (out= 90)(deflated 98%)
|
|
563 |
.fl
|
|
564 |
adding: audio/3.au(in = 11616) (out= 108)(deflated 99%)
|
|
565 |
.fl
|
|
566 |
adding: audio/spacemusic.au(in = 3079) (out= 73)(deflated 97%)
|
|
567 |
.fl
|
|
568 |
adding: classes/(in = 0) (out= 0)(stored 0%)
|
|
569 |
.fl
|
|
570 |
adding: classes/Animator.class(in = 2266) (out= 66)(deflated 97%)
|
|
571 |
.fl
|
|
572 |
adding: classes/Wave.class(in = 3778) (out= 81)(deflated 97%)
|
|
573 |
.fl
|
|
574 |
adding: images/(in = 0) (out= 0)(stored 0%)
|
|
575 |
.fl
|
|
576 |
adding: images/monkey.jpg(in = 7667) (out= 91)(deflated 98%)
|
|
577 |
.fl
|
|
578 |
adding: images/at_work.gif(in = 6621) (out= 89)(deflated 98%)
|
|
579 |
.fl
|
|
580 |
|
|
581 |
.fl
|
|
582 |
% ls \-F
|
|
583 |
.fl
|
|
584 |
audio/ bundle.jar classes/ images/
|
|
585 |
.fl
|
|
586 |
\fP
|
|
587 |
.fi
|
|
588 |
.RE
|
|
589 |
|
|
590 |
.LP
|
|
591 |
To see the entry names in the jarfile, use the \f2t\fP option:
|
|
592 |
.RS 3
|
|
593 |
|
|
594 |
.LP
|
|
595 |
.nf
|
|
596 |
\f3
|
|
597 |
.fl
|
|
598 |
% jar tf bundle.jar
|
|
599 |
.fl
|
|
600 |
META\-INF/
|
|
601 |
.fl
|
|
602 |
META\-INF/MANIFEST.MF
|
|
603 |
.fl
|
|
604 |
audio/1.au
|
|
605 |
.fl
|
|
606 |
audio/2.au
|
|
607 |
.fl
|
|
608 |
audio/3.au
|
|
609 |
.fl
|
|
610 |
audio/spacemusic.au
|
|
611 |
.fl
|
|
612 |
classes/Animator.class
|
|
613 |
.fl
|
|
614 |
classes/Wave.class
|
|
615 |
.fl
|
|
616 |
images/monkey.jpg
|
|
617 |
.fl
|
|
618 |
images/at_work.gif
|
|
619 |
.fl
|
|
620 |
\fP
|
|
621 |
.fi
|
|
622 |
.RE
|
|
623 |
|
|
624 |
.LP
|
|
625 |
.LP
|
|
626 |
To add an index file to the jar file for speeding up class loading, use the \f2i\fP option.
|
|
627 |
.br
|
|
628 |
.br
|
|
629 |
Example:
|
|
630 |
.br
|
|
631 |
|
|
632 |
.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.
|
|
637 |
.br
|
|
638 |
|
|
639 |
.LP
|
|
640 |
.br
|
|
641 |
|
|
642 |
.LP
|
|
643 |
If you specify the \f2Class\-path\fP attribute in the \f2main.jar\fP manifest as:
|
|
644 |
.nf
|
|
645 |
\f3
|
|
646 |
.fl
|
|
647 |
Class\-Path: buy.jar sell.jar
|
|
648 |
.fl
|
|
649 |
\fP
|
|
650 |
.fi
|
|
651 |
|
|
652 |
.LP
|
|
653 |
then you can use the \f2\-i\fP option to speed up the class loading time for your application:
|
|
654 |
.nf
|
|
655 |
\f3
|
|
656 |
.fl
|
|
657 |
% jar i main.jar
|
|
658 |
.fl
|
|
659 |
\fP
|
|
660 |
.fi
|
|
661 |
|
|
662 |
.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.
|
|
664 |
.RE
|
|
665 |
.SH "SEE ALSO"
|
|
666 |
.LP
|
|
667 |
|
|
668 |
.LP
|
|
669 |
.na
|
|
670 |
\f2The Jar Overview\fP @
|
|
671 |
.fi
|
2692
|
672 |
http://java.sun.com/javase/6/docs/technotes/guides/jar/jarGuide.html
|
2
|
673 |
.br
|
|
674 |
|
|
675 |
.LP
|
|
676 |
.na
|
|
677 |
\f2The Jar File Specification\fP @
|
|
678 |
.fi
|
2692
|
679 |
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
|
2
|
680 |
.br
|
|
681 |
|
|
682 |
.LP
|
|
683 |
.na
|
|
684 |
\f2The JarIndex Spec\fP @
|
|
685 |
.fi
|
2692
|
686 |
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Index
|
2
|
687 |
.br
|
|
688 |
|
|
689 |
.LP
|
|
690 |
.na
|
|
691 |
\f2Jar Tutorial\fP @
|
|
692 |
.fi
|
|
693 |
http://java.sun.com/docs/books/tutorial/jar on the Java Software web site.
|
|
694 |
.br
|
|
695 |
|
|
696 |
.LP
|
5865
|
697 |
pack200(1)
|