1 ." Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved. |
1 '\" t |
2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2 .\" Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. |
3 ." |
3 .\" |
4 ." This code is free software; you can redistribute it and/or modify it |
4 .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 ." under the terms of the GNU General Public License version 2 only, as |
5 .\" |
6 ." published by the Free Software Foundation. |
6 .\" This code is free software; you can redistribute it and/or modify it |
7 ." |
7 .\" under the terms of the GNU General Public License version 2 only, as |
8 ." This code is distributed in the hope that it will be useful, but WITHOUT |
8 .\" published by the Free Software Foundation. |
9 ." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9 .\" |
10 ." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
10 .\" This code is distributed in the hope that it will be useful, but WITHOUT |
11 ." version 2 for more details (a copy is included in the LICENSE file that |
11 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
12 ." accompanied this code). |
12 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13 ." |
13 .\" version 2 for more details (a copy is included in the LICENSE file that |
14 ." You should have received a copy of the GNU General Public License version |
14 .\" accompanied this code). |
15 ." 2 along with this work; if not, write to the Free Software Foundation, |
15 .\" |
16 ." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
16 .\" You should have received a copy of the GNU General Public License version |
17 ." |
17 .\" 2 along with this work; if not, write to the Free Software Foundation, |
18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
18 .\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
19 ." or visit www.oracle.com if you need additional information or have any |
19 .\" |
20 ." questions. |
20 .\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
21 ." |
21 .\" or visit www.oracle.com if you need additional information or have any |
22 .TH javac 1 "10 May 2011" |
22 .\" questions. |
23 |
23 .\" |
24 .LP |
24 .\" Arch: generic |
25 .SH "Name" |
25 .\" Software: JDK 8 |
26 javac \- Java programming language compiler |
26 .\" Date: 21 November 2013 |
27 .LP |
27 .\" SectDesc: Basic Tools |
28 .SH "SYNOPSIS" |
28 .\" Title: javac.1 |
29 .LP |
29 .\" |
30 .nf |
30 .if n .pl 99999 |
31 \f3 |
31 .TH javac 1 "21 November 2013" "JDK 8" "Basic Tools" |
32 .fl |
32 .\" ----------------------------------------------------------------- |
33 \fP\f3javac\fP [ options ] [ sourcefiles ] [ classes ] [ @argfiles ] |
33 .\" * Define some portability stuff |
34 .fl |
34 .\" ----------------------------------------------------------------- |
35 |
35 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
36 .fl |
36 .\" http://bugs.debian.org/507673 |
37 .fi |
37 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
38 |
38 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
39 .LP |
39 .ie \n(.g .ds Aq \(aq |
40 .LP |
40 .el .ds Aq ' |
41 Arguments may be in any order. |
41 .\" ----------------------------------------------------------------- |
42 .LP |
42 .\" * set default formatting |
43 .RS 3 |
43 .\" ----------------------------------------------------------------- |
44 .TP 3 |
44 .\" disable hyphenation |
|
45 .nh |
|
46 .\" disable justification (adjust text to left margin only) |
|
47 .ad l |
|
48 .\" ----------------------------------------------------------------- |
|
49 .\" * MAIN CONTENT STARTS HERE * |
|
50 .\" ----------------------------------------------------------------- |
|
51 |
|
52 .SH NAME |
|
53 javac \- Reads Java class and interface definitions and compiles them into bytecode and class files\&. |
|
54 .SH SYNOPSIS |
|
55 .sp |
|
56 .nf |
|
57 |
|
58 \fBjavac\fR [ \fIoptions\fR ] [ \fIsourcefiles\fR ] [ \fIclasses\fR] [ \fI@argfiles\fR ] |
|
59 .fi |
|
60 .sp |
|
61 Arguments can be in any order: |
|
62 .TP |
|
63 \fIoptions\fR |
|
64 Command-line options\&. See Options\&. |
|
65 .TP |
|
66 \fIsourcefiles\fR |
|
67 One or more source files to be compiled (such as \f3MyClass\&.java\fR)\&. |
|
68 .TP |
|
69 \fIclasses\fR |
|
70 One or more classes to be processed for annotations (such as \f3MyPackage\&.MyClass\fR)\&. |
|
71 .TP |
|
72 \fI@argfiles\fR |
|
73 One or more files that list options and source files\&. The \f3-J\fR options are not allowed in these files\&. See Command-Line Argument Files\&. |
|
74 .SH DESCRIPTION |
|
75 The \f3javac\fR command reads class and interface definitions, written in the Java programming language, and compiles them into bytecode class files\&. The \f3javac\fR command can also process annotations in Java source files and classes\&. |
|
76 .PP |
|
77 There are two ways to pass source code file names to \f3javac\fR\&. |
|
78 .TP 0.2i |
|
79 \(bu |
|
80 For a small number of source files, list the file names on the command line\&. |
|
81 .TP 0.2i |
|
82 \(bu |
|
83 For a large number of source files, list the file names in a file that is separated by blanks or line breaks\&. Use the list file name preceded by an at sign (@) with the \f3javac\fR command\&. |
|
84 .PP |
|
85 Source code file names must have \&.java suffixes, class file names must have \&.class suffixes, and both source and class files must have root names that identify the class\&. For example, a class called \f3MyClass\fR would be written in a source file called \f3MyClass\&.java\fR and compiled into a bytecode class file called \f3MyClass\&.class\fR\&. |
|
86 .PP |
|
87 Inner class definitions produce additional class files\&. These class files have names that combine the inner and outer class names, such as \f3MyClass$MyInnerClass\&.class\fR\&. |
|
88 .PP |
|
89 Arrange source files in a directory tree that reflects their package tree\&. For example, if all of your source files are in \f3/workspace\fR, then put the source code for \f3com\&.mysoft\&.mypack\&.MyClass\fR in \f3/workspace/com/mysoft/mypack/MyClass\&.java\fR\&. |
|
90 .PP |
|
91 By default, the compiler puts each class file in the same directory as its source file\&. You can specify a separate destination directory with the \f3-d\fR option\&. |
|
92 .SH OPTIONS |
|
93 The compiler has a set of standard options that are supported on the current development environment\&. An additional set of nonstandard options are specific to the current virtual machine and compiler implementations and are subject to change in the future\&. Nonstandard options begin with the \f3-X\fR option\&. |
|
94 .TP 0.2i |
|
95 \(bu |
|
96 See also Cross-Compilation Options |
|
97 .TP 0.2i |
|
98 \(bu |
|
99 See also Nonstandard Options |
|
100 .SS STANDARD\ OPTIONS |
|
101 .TP |
|
102 -A\fIkey\fR[\fI=value\fR] |
|
103 .br |
|
104 Specifies options to pass to annotation processors\&. These options are not interpreted by \f3javac\fR directly, but are made available for use by individual processors\&. The \f3key\fR value should be one or more identifiers separated by a dot (\&.)\&. |
|
105 .TP |
|
106 -cp \fIpath\fR or -classpath \fIpath\fR |
|
107 .br |
|
108 Specifies where to find user class files, and (optionally) annotation processors and source files\&. This class path overrides the user class path in the \f3CLASSPATH\fR environment variable\&. If neither \f3CLASSPATH\fR, \f3-cp\fR nor \f3-classpath\fR is specified, then the user \fIclass path\fR is the current directory\&. See Setting the Class Path\&. |
|
109 |
|
110 If the \f3-sourcepath\fR option is not specified, then the user class path is also searched for source files\&. |
|
111 |
|
112 If the \f3-processorpath\fR option is not specified, then the class path is also searched for annotation processors\&. |
|
113 .TP |
|
114 -Djava\&.ext\&.dirs=\fIdirectories\fR |
|
115 .br |
|
116 Overrides the location of installed extensions\&. |
|
117 .TP |
|
118 -Djava\&.endorsed\&.dirs=\fIdirectories\fR |
|
119 .br |
|
120 Overrides the location of the endorsed standards path\&. |
|
121 .TP |
|
122 -d \fIdirectory\fR |
|
123 .br |
|
124 Sets the destination directory for class files\&. The directory must already exist because \f3javac\fR does not create it\&. If a class is part of a package, then \f3javac\fR puts the class file in a subdirectory that reflects the package name and creates directories as needed\&. |
|
125 |
|
126 If you specify \f3-d\fR\f3/home/myclasses\fR and the class is called \f3com\&.mypackage\&.MyClass\fR, then the class file is \f3/home/myclasses/com/mypackage/MyClass\&.class\fR\&. |
|
127 |
|
128 If the \fI-d\fR option is not specified, then \f3javac\fR puts each class file in the same directory as the source file from which it was generated\&. |
|
129 |
|
130 \fINote:\fR The directory specified by the \fI-d\fR option is not automatically added to your user class path\&. |
|
131 .TP |
|
132 -deprecation |
|
133 .br |
|
134 Shows a description of each use or override of a deprecated member or class\&. Without the \f3-deprecation\fR option, \f3javac\fR shows a summary of the source files that use or override deprecated members or classes\&. The \f3-deprecation\fR option is shorthand for \f3-Xlint:deprecation\fR\&. |
|
135 .TP |
|
136 -encoding \fIencoding\fR |
|
137 .br |
|
138 Sets the source file encoding name, such as EUC-JP and UTF-8\&. If the \f3-encoding\fR option is not specified, then the platform default converter is used\&. |
|
139 .TP |
|
140 -endorseddirs \fIdirectories\fR |
|
141 .br |
|
142 Overrides the location of the endorsed standards path\&. |
|
143 .TP |
|
144 -extdirs \fIdirectories\fR |
|
145 .br |
|
146 Overrides the location of the \f3ext\fR directory\&. The directories variable is a colon-separated list of directories\&. Each JAR file in the specified directories is searched for class files\&. All JAR files found become part of the class path\&. |
|
147 |
|
148 If you are cross-compiling (compiling classes against bootstrap and extension classes of a different Java platform implementation), then this option specifies the directories that contain the extension classes\&. See Cross-Compilation Options for more information\&. |
|
149 .TP |
|
150 -g |
|
151 .br |
|
152 Generates all debugging information, including local variables\&. By default, only line number and source file information is generated\&. |
|
153 .TP |
|
154 -g:none |
|
155 .br |
|
156 Does not generate any debugging information\&. |
|
157 .TP |
|
158 -g:[\fIkeyword list\fR] |
|
159 .br |
|
160 Generates only some kinds of debugging information, specified by a comma separated list of keywords\&. Valid keywords are: |
|
161 .RS |
|
162 .TP |
|
163 source |
|
164 Source file debugging information\&. |
|
165 .TP |
|
166 lines |
|
167 Line number debugging information\&. |
|
168 .TP |
|
169 vars |
|
170 Local variable debugging information\&. |
|
171 .RE |
|
172 |
|
173 .TP |
|
174 -help |
|
175 .br |
|
176 Prints a synopsis of standard options\&. |
|
177 .TP |
|
178 -implicit:[\fIclass, none\fR] |
|
179 .br |
|
180 Controls the generation of class files for implicitly loaded source files\&. To automatically generate class files, use \f3-implicit:class\fR\&. To suppress class file generation, use \f3-implicit:none\fR\&. If this option is not specified, then the default is to automatically generate class files\&. In this case, the compiler issues a warning if any such class files are generated when also doing annotation processing\&. The warning is not issued when the \f3-implicit\fR option is set explicitly\&. See Searching for Types\&. |
|
181 .TP |
|
182 -J\fIoption\fR |
|
183 .br |
|
184 Passes \f3option\fR to the Java Virtual Machine (JVM), where option is one of the options described on the reference page for the Java launcher\&. For example, \f3-J-Xms48m\fR sets the startup memory to 48 MB\&. See java(1)\&. |
|
185 |
|
186 \fINote:\fR The \fICLASSPATH\fR, \f3-classpath\fR, \f3-bootclasspath\fR, and \f3-extdirs\fR options do not specify the classes used to run \f3javac\fR\&. Trying to customize the compiler implementation with these options and variables is risky and often does not accomplish what you want\&. If you must customize the complier implementation, then use the \f3-J\fR option to pass options through to the underlying \f3\fRJava launcher\&. |
|
187 .TP |
|
188 -nowarn |
|
189 .br |
|
190 Disables warning messages\&. This option operates the same as the \f3-Xlint:none\fR option\&. |
|
191 .TP |
|
192 -parameters |
|
193 .br |
|
194 Stores formal parameter names of constructors and methods in the generated class file so that the method \f3java\&.lang\&.reflect\&.Executable\&.getParameters\fR from the Reflection API can retrieve them\&. |
|
195 .TP |
|
196 -proc: [\fInone\fR, \fIonly\fR] |
|
197 .br |
|
198 Controls whether annotation processing and compilation are done\&. \f3-proc:none\fR means that compilation takes place without annotation processing\&. \f3-proc:only\fR means that only annotation processing is done, without any subsequent compilation\&. |
|
199 .TP |
|
200 -processor \fIclass1\fR [,\fIclass2\fR,\fIclass3\fR\&.\&.\&.] |
|
201 .br |
|
202 Names of the annotation processors to run\&. This bypasses the default discovery process\&. |
|
203 .TP |
|
204 -processorpath \fIpath\fR |
|
205 .br |
|
206 Specifies where to find annotation processors\&. If this option is not used, then the class path is searched for processors\&. |
|
207 .TP |
|
208 -s \fIdir\fR |
|
209 .br |
|
210 Specifies the directory where to place the generated source files\&. The directory must already exist because \f3javac\fR does not create it\&. If a class is part of a package, then the compiler puts the source file in a subdirectory that reflects the package name and creates directories as needed\&. |
|
211 |
|
212 If you specify \f3-s /home/mysrc\fR and the class is called \f3com\&.mypackage\&.MyClass\fR, then the source file is put in \f3/home/mysrc/com/mypackage/MyClass\&.java\fR\&. |
|
213 .TP |
|
214 -source \fIrelease\fR |
|
215 .br |
|
216 Specifies the version of source code accepted\&. The following values for \f3release\fR are allowed: |
|
217 .RS |
|
218 .TP |
|
219 1\&.3 |
|
220 The compiler does not support assertions, generics, or other language features introduced after Java SE 1\&.3\&. |
|
221 .TP |
|
222 1\&.4 |
|
223 The compiler accepts code containing assertions, which were introduced in Java SE 1\&.4\&. |
|
224 .TP |
|
225 1\&.5 |
|
226 The compiler accepts code containing generics and other language features introduced in Java SE 5\&. |
|
227 .TP |
|
228 5 |
|
229 Synonym for 1\&.5\&. |
|
230 .TP |
|
231 1\&.6 |
|
232 No language changes were introduced in Java SE 6\&. However, encoding errors in source files are now reported as errors instead of warnings as in earlier releases of Java Platform, Standard Edition\&. |
|
233 .TP |
|
234 6 |
|
235 Synonym for 1\&.6\&. |
|
236 .TP |
|
237 1\&.7 |
|
238 This is the default value\&. The compiler accepts code with features introduced in Java SE 7\&. |
|
239 .TP |
|
240 7 |
|
241 Synonym for 1\&.7\&. |
|
242 .RE |
|
243 |
|
244 .TP |
|
245 -sourcepath \fIsourcepath\fR |
|
246 .br |
|
247 Specifies the source code path to search for class or interface definitions\&. As with the user class path, source path entries are separated by colons (:) on Oracle Solaris and semicolons on Windows and can be directories, JAR archives, or ZIP archives\&. If packages are used, then the local path name within the directory or archive must reflect the package name\&. |
|
248 |
|
249 \fINote:\fR Classes found through the class path might be recompiled when their source files are also found\&. See Searching for Types\&. |
|
250 .TP |
|
251 -verbose |
|
252 .br |
|
253 Uses verbose output, which includes information about each class loaded and each source file compiled\&. |
|
254 .TP |
|
255 -version |
|
256 .br |
|
257 Prints release information\&. |
|
258 .TP |
|
259 -werror |
|
260 .br |
|
261 Terminates compilation when warnings occur\&. |
|
262 .TP |
|
263 -X |
|
264 .br |
|
265 Displays information about nonstandard options and exits\&. |
|
266 .SS CROSS-COMPILATION\ OPTIONS |
|
267 By default, classes are compiled against the bootstrap and extension classes of the platform that \f3javac\fR shipped with\&. But \f3javac\fR also supports cross-compiling, where classes are compiled against a bootstrap and extension classes of a different Java platform implementation\&. It is important to use the \f3-bootclasspath\fR and \f3-extdirs\fR options when cross-compiling\&. |
|
268 .TP |
|
269 -target \fIversion\fR |
|
270 .br |
|
271 Generates class files that target a specified release of the virtual machine\&. Class files will run on the specified target and on later releases, but not on earlier releases of the JVM\&. Valid targets are 1\&.1, 1\&.2, 1\&.3, 1\&.4, 1\&.5 (also 5), 1\&.6 (also 6), and 1\&.7 (also 7)\&. |
|
272 |
|
273 The default for the \f3-target\fR option depends on the value of the \f3-source\fR option: |
|
274 .RS |
|
275 .TP 0.2i |
|
276 \(bu |
|
277 If the \f3-source\fR option is not specified, then the value of the \f3-target\fR option is 1\&.7 |
|
278 .TP 0.2i |
|
279 \(bu |
|
280 If the \f3-source\fR option is 1\&.2, then the value of the \f3-target\fR option is 1\&.4 |
|
281 .TP 0.2i |
|
282 \(bu |
|
283 If the \f3-source\fR option is 1\&.3, then the value of the \f3-target\fR option is 1\&.4 |
|
284 .TP 0.2i |
|
285 \(bu |
|
286 If the \f3-source\fR option is 1\&.5, then the value of the \f3-target\fR option is 1\&.7 |
|
287 .TP 0.2i |
|
288 \(bu |
|
289 If the \f3-source\fR option is 1\&.6, then the value of the \f3-target\fR is option 1\&.7 |
|
290 .TP 0.2i |
|
291 \(bu |
|
292 For all other values of the \f3-source\fR option, the value of the \f3-target\fR option is the value of the \f3-source\fR option\&. |
|
293 .RE |
|
294 |
|
295 .TP |
|
296 -bootclasspath \fIbootclasspath\fR |
|
297 .br |
|
298 Cross-compiles against the specified set of boot classes\&. As with the user class path, boot class path entries are separated by colons (:) and can be directories, JAR archives, or ZIP archives\&. |
|
299 .SS COMPACT\ PROFILE\ OPTION |
|
300 Beginning with JDK 8, the \f3javac\fR compiler supports compact profiles\&. With compact profiles, applications that do not require the entire Java platform can be deployed and run with a smaller footprint\&. The compact profiles feature could be used to shorten the download time for applications from app stores\&. This feature makes for more compact deployment of Java applications that bundle the JRE\&. This feature is also useful in small devices\&. |
|
301 .PP |
|
302 The supported profile values are \f3compact1\fR, \f3compact2\fR, and \f3compact3\fR\&. These are additive layers\&. Each higher-numbered compact profile contains all of the APIs in profiles with smaller number names\&. |
|
303 .TP |
|
304 -profile |
|
305 .br |
|
306 When using compact profiles, this option specifies the profile name when compiling\&. For example: |
|
307 .sp |
|
308 .nf |
|
309 \f3javac \-profile compact1 Hello\&.java\fP |
|
310 .fi |
|
311 .nf |
|
312 \f3\fP |
|
313 .fi |
|
314 .sp |
|
315 |
|
316 |
|
317 javac does not compile source code that uses any Java SE APIs that is not in the specified profile\&. Here is an example of the error message that results from attempting to compile such source code: |
|
318 .sp |
|
319 .nf |
|
320 \f3cd jdk1\&.8\&.0/bin\fP |
|
321 .fi |
|
322 .nf |
|
323 \f3\&./javac \-profile compact1 Paint\&.java\fP |
|
324 .fi |
|
325 .nf |
|
326 \f3Paint\&.java:5: error: Applet is not available in profile \&'compact1\&'\fP |
|
327 .fi |
|
328 .nf |
|
329 \f3import java\&.applet\&.Applet;\fP |
|
330 .fi |
|
331 .nf |
|
332 \f3\fP |
|
333 .fi |
|
334 .sp |
|
335 |
|
336 |
|
337 In this example, you can correct the error by modifying the source to not use the \f3Applet\fR class\&. You could also correct the error by compiling without the -profile option\&. Then the compilation would be run against the full set of Java SE APIs\&. (None of the compact profiles include the \f3Applet\fR class\&.) |
|
338 |
|
339 An alternative way to compile with compact profiles is to use the \f3-bootclasspath\fR option to specify a path to an \f3rt\&.jar\fR file that specifies a profile\&'s image\&. Using the \f3-profile\fR option instead does not require a profile image to be present on the system at compile time\&. This is useful when cross-compiling\&. |
|
340 .SS NONSTANDARD\ OPTIONS |
|
341 .TP |
|
342 -Xbootclasspath/p:\fIpath\fR |
|
343 .br |
|
344 Adds a suffix to the bootstrap class path\&. |
|
345 .TP |
|
346 -Xbootclasspath/a:\fIpath\fR |
|
347 .br |
|
348 Adds a prefix to the bootstrap class path\&. |
|
349 .TP |
|
350 -Xbootclasspath/:\fIpath\fR |
|
351 .br |
|
352 Overrides the location of the bootstrap class files\&. |
|
353 .TP |
|
354 -Xdoclint:[-]\fIgroup\fR [\fI/access\fR] |
|
355 .br |
|
356 Enables or disables specific groups of checks, where \fIgroup\fR is one of the following values: \f3accessibility\fR, \f3syntax\fR, \f3reference\fR, \f3html\fR or \f3missing\fR\&. For more information about these groups of checks see the \f3-Xdoclint\fR option of the \f3javadoc\fR command\&. The \f3-Xdoclint\fR option is disabled by default in the \f3javac\fR command\&. |
|
357 |
|
358 The variable \fIaccess\fR specifies the minimum visibility level of classes and members that the \f3-Xdoclint\fR option checks\&. It can have one of the following values (in order of most to least visible) : \f3public\fR, \f3protected\fR, \f3package\fR and \f3private\fR\&. For example, the following option checks classes and members (with all groups of checks) that have the access level protected and higher (which includes protected, package and public): |
|
359 .sp |
|
360 .nf |
|
361 \f3\-Xdoclint:all/protected\fP |
|
362 .fi |
|
363 .nf |
|
364 \f3\fP |
|
365 .fi |
|
366 .sp |
|
367 |
|
368 |
|
369 The following option enables all groups of checks for all access levels, except it will not check for HTML errors for classes and members that have access level package and higher (which includes package and public): |
|
370 .sp |
|
371 .nf |
|
372 \f3\-Xdoclint:all,\-html/package\fP |
|
373 .fi |
|
374 .nf |
|
375 \f3\fP |
|
376 .fi |
|
377 .sp |
|
378 |
|
379 .TP |
|
380 -Xdoclint:none |
|
381 .br |
|
382 Disables all groups of checks\&. |
|
383 .TP |
|
384 -Xdoclint:all[\fI/access\fR] |
|
385 .br |
|
386 Enables all groups of checks\&. |
|
387 .TP |
|
388 -Xlint |
|
389 .br |
|
390 \fI\fREnables all recommended warnings\&. In this release, enabling all available warnings is recommended\&. |
|
391 .TP |
|
392 -Xlint:all |
|
393 .br |
|
394 \fI\fREnables all recommended warnings\&. In this release, enabling all available warnings is recommended\&. |
|
395 .TP |
|
396 -Xlint:none |
|
397 .br |
|
398 Disables all warnings\&. |
|
399 .TP |
|
400 -Xlint:\fIname\fR |
|
401 .br |
|
402 Disables warning name\&. See Enable or Disable Warnings with the -Xlint Option for a list of warnings you can disable with this option\&. |
|
403 .TP |
|
404 -Xlint:\fI-name\fR |
|
405 .br |
|
406 Disables warning name\&. See Enable or Disable Warnings with the -Xlint Option with the \f3-Xlint\fR option to get a list of warnings that you can disable with this option\&. |
|
407 .TP |
|
408 -Xmaxerrs \fInumber\fR |
|
409 .br |
|
410 Sets the maximum number of errors to print\&. |
|
411 .TP |
|
412 -Xmaxwarns \fInumber\fR |
|
413 .br |
|
414 Sets the maximum number of warnings to print\&. |
|
415 .TP |
|
416 -Xstdout \fIfilename\fR |
|
417 .br |
|
418 Sends compiler messages to the named file\&. By default, compiler messages go to \f3System\&.err\fR\&. |
|
419 .TP |
|
420 -Xprefer:[\fInewer,source\fR] |
|
421 .br |
|
422 Specifies which file to read when both a source file and class file are found for a type\&. (See Searching for Types)\&. If the \f3-Xprefer:newer\fR option is used, then it reads the newer of the source or class file for a type (default)\&. If the \f3-Xprefer:source\fR option is used, then it reads the source file\&. Use -\f3Xprefer:source\fR when you want to be sure that any annotation processors can access annotations declared with a retention policy of \f3SOURCE\fR\&. |
|
423 .TP |
|
424 -Xpkginfo:[\fIalways\fR,\fIlegacy\fR,\fInonempty\fR] |
|
425 .br |
|
426 Control whether javac generates \f3package-info\&.class\fR files from package-info\&.java files\&. Possible mode arguments for this option include the following\&. |
|
427 .RS |
|
428 .TP |
|
429 always |
|
430 Always generate a \f3package-info\&.class\fR file for every \f3package-info\&.java\fR file\&. This option may be useful if you use a build system such as Ant, which checks that each \f3\&.java\fR file has a corresponding \f3\&.class\fR file\&. |
|
431 .TP |
|
432 legacy |
|
433 Generate a \f3package-info\&.class\fR file only if package-info\&.java contains annotations\&. Don\&'t generate a \f3package-info\&.class\fR file if package-info\&.java only contains comments\&. |
|
434 |
|
435 \fINote:\fR A \f3package-info\&.class\fR file might be generated but be empty if all the annotations in the package-info\&.java file have \f3RetentionPolicy\&.SOURCE\fR\&. |
|
436 .TP |
|
437 nonempty |
|
438 Generate a \f3package-info\&.class\fR file only if package-info\&.java contains annotations with \f3RetentionPolicy\&.CLASS\fR or \f3RetentionPolicy\&.RUNTIME\fR\&. |
|
439 .RE |
|
440 |
|
441 .TP |
|
442 -Xprint |
|
443 .br |
|
444 Prints a textual representation of specified types for debugging purposes\&. Perform neither annotation processing nor compilation\&. The format of the output could change\&. |
|
445 .TP |
|
446 -XprintProcessorInfo |
|
447 .br |
|
448 Prints information about which annotations a processor is asked to process\&. |
|
449 .TP |
|
450 -XprintRounds |
|
451 .br |
|
452 Prints information about initial and subsequent annotation processing rounds\&. |
|
453 .SH ENABLE\ OR\ DISABLE\ WARNINGS\ WITH\ THE\ -XLINT\ OPTION |
|
454 Enable warning \fIname\fR with the \f3-Xlint:name\fR option, where \f3name\fR is one of the following warning names\&. Note that you can disable a warning with the \f3-Xlint:-name:\fR option\&. |
|
455 .TP |
|
456 cast |
|
457 Warns about unnecessary and redundant casts, for example: |
|
458 .sp |
|
459 .nf |
|
460 \f3String s = (String) "Hello!"\fP |
|
461 .fi |
|
462 .nf |
|
463 \f3\fP |
|
464 .fi |
|
465 .sp |
|
466 |
|
467 .TP |
|
468 classfile |
|
469 Warns about issues related to class file contents\&. |
|
470 .TP |
|
471 deprecation |
|
472 Warns about the use of deprecated items, for example: |
|
473 .sp |
|
474 .nf |
|
475 \f3java\&.util\&.Date myDate = new java\&.util\&.Date();\fP |
|
476 .fi |
|
477 .nf |
|
478 \f3int currentDay = myDate\&.getDay();\fP |
|
479 .fi |
|
480 .nf |
|
481 \f3\fP |
|
482 .fi |
|
483 .sp |
|
484 |
|
485 |
|
486 The method \f3java\&.util\&.Date\&.getDay\fR has been deprecated since JDK 1\&.1 |
|
487 .TP |
|
488 dep-ann |
|
489 Warns about items that are documented with an \f3@deprecated\fR Javadoc comment, but do not have a \f3@Deprecated\fR annotation, for example: |
|
490 .sp |
|
491 .nf |
|
492 \f3/**\fP |
|
493 .fi |
|
494 .nf |
|
495 \f3 * @deprecated As of Java SE 7, replaced by {@link #newMethod()}\fP |
|
496 .fi |
|
497 .nf |
|
498 \f3 */\fP |
|
499 .fi |
|
500 .nf |
|
501 \f3public static void deprecatedMethood() { }\fP |
|
502 .fi |
|
503 .nf |
|
504 \f3public static void newMethod() { }\fP |
|
505 .fi |
|
506 .nf |
|
507 \f3\fP |
|
508 .fi |
|
509 .sp |
|
510 |
|
511 .TP |
|
512 divzero |
|
513 Warns about division by the constant integer 0, for example: |
|
514 .sp |
|
515 .nf |
|
516 \f3int divideByZero = 42 / 0;\fP |
|
517 .fi |
|
518 .nf |
|
519 \f3\fP |
|
520 .fi |
|
521 .sp |
|
522 |
|
523 .TP |
|
524 empty |
|
525 Warns about empty statements after \f3if\fRstatements, for example: |
|
526 .sp |
|
527 .nf |
|
528 \f3class E {\fP |
|
529 .fi |
|
530 .nf |
|
531 \f3 void m() {\fP |
|
532 .fi |
|
533 .nf |
|
534 \f3 if (true) ;\fP |
|
535 .fi |
|
536 .nf |
|
537 \f3 }\fP |
|
538 .fi |
|
539 .nf |
|
540 \f3}\fP |
|
541 .fi |
|
542 .nf |
|
543 \f3\fP |
|
544 .fi |
|
545 .sp |
|
546 |
|
547 .TP |
|
548 fallthrough |
|
549 Checks the switch blocks for fall-through cases and provides a warning message for any that are found\&. Fall-through cases are cases in a switch block, other than the last case in the block, whose code does not include a break statement, allowing code execution to fall through from that case to the next case\&. For example, the code following the case 1 label in this switch block does not end with a break statement: |
|
550 .sp |
|
551 .nf |
|
552 \f3switch (x) {\fP |
|
553 .fi |
|
554 .nf |
|
555 \f3case 1:\fP |
|
556 .fi |
|
557 .nf |
|
558 \f3 System\&.out\&.println("1");\fP |
|
559 .fi |
|
560 .nf |
|
561 \f3 // No break statement here\&.\fP |
|
562 .fi |
|
563 .nf |
|
564 \f3case 2:\fP |
|
565 .fi |
|
566 .nf |
|
567 \f3 System\&.out\&.println("2");\fP |
|
568 .fi |
|
569 .nf |
|
570 \f3}\fP |
|
571 .fi |
|
572 .nf |
|
573 \f3\fP |
|
574 .fi |
|
575 .sp |
|
576 |
|
577 |
|
578 If the \f3-Xlint:fallthrough\fR option was used when compiling this code, then the compiler emits a warning about possible fall-through into case, with the line number of the case in question\&. |
|
579 .TP |
|
580 finally |
|
581 Warns about \f3finally\fR clauses that cannot complete normally, for example: |
|
582 .sp |
|
583 .nf |
|
584 \f3public static int m() {\fP |
|
585 .fi |
|
586 .nf |
|
587 \f3 try {\fP |
|
588 .fi |
|
589 .nf |
|
590 \f3 throw new NullPointerException();\fP |
|
591 .fi |
|
592 .nf |
|
593 \f3 } catch (NullPointerException(); {\fP |
|
594 .fi |
|
595 .nf |
|
596 \f3 System\&.err\&.println("Caught NullPointerException\&.");\fP |
|
597 .fi |
|
598 .nf |
|
599 \f3 return 1;\fP |
|
600 .fi |
|
601 .nf |
|
602 \f3 } finally {\fP |
|
603 .fi |
|
604 .nf |
|
605 \f3 return 0;\fP |
|
606 .fi |
|
607 .nf |
|
608 \f3 }\fP |
|
609 .fi |
|
610 .nf |
|
611 \f3 }\fP |
|
612 .fi |
|
613 .nf |
|
614 \f3\fP |
|
615 .fi |
|
616 .sp |
|
617 |
|
618 |
|
619 The compiler generates a warning for the \f3finally\fR block in this example\&. When the \f3int\fR method is called, it returns a value of 0\&. A \f3finally\fR block executes when the \f3try\fR block exits\&. In this example, when control is transferred to the \f3catch\fR block, the \f3int\fR method exits\&. However, the \f3finally\fR block must execute, so it is executed, even though control was transferred outside the method\&. |
|
620 .TP |
45 options |
621 options |
46 Command\-line options. |
622 Warns about issues that related to the use of command-line options\&. See Cross-Compilation Options\&. |
47 .TP 3 |
623 .TP |
48 sourcefiles |
624 overrides |
49 One or more source files to be compiled (such as MyClass.java). |
625 Warns about issues regarding method overrides\&. For example, consider the following two classes: |
50 .TP 3 |
626 .sp |
51 classes |
627 .nf |
52 One or more classes to be processed for annotations (such as MyPackage.MyClass). |
628 \f3public class ClassWithVarargsMethod {\fP |
53 .TP 3 |
629 .fi |
54 @argfiles |
630 .nf |
55 One or more files that lists options and source files. The \f2\-J\fP options are not allowed in these files. |
631 \f3 void varargsMethod(String\&.\&.\&. s) { }\fP |
|
632 .fi |
|
633 .nf |
|
634 \f3}\fP |
|
635 .fi |
|
636 .nf |
|
637 \f3\fP |
|
638 .fi |
|
639 .nf |
|
640 \f3public class ClassWithOverridingMethod extends ClassWithVarargsMethod {\fP |
|
641 .fi |
|
642 .nf |
|
643 \f3 @Override\fP |
|
644 .fi |
|
645 .nf |
|
646 \f3 void varargsMethod(String[] s) { }\fP |
|
647 .fi |
|
648 .nf |
|
649 \f3}\fP |
|
650 .fi |
|
651 .nf |
|
652 \f3\fP |
|
653 .fi |
|
654 .sp |
|
655 |
|
656 |
|
657 The compiler generates a warning similar to the following:\&. |
|
658 .sp |
|
659 .nf |
|
660 \f3warning: [override] varargsMethod(String[]) in ClassWithOverridingMethod \fP |
|
661 .fi |
|
662 .nf |
|
663 \f3overrides varargsMethod(String\&.\&.\&.) in ClassWithVarargsMethod; overriding\fP |
|
664 .fi |
|
665 .nf |
|
666 \f3method is missing \&'\&.\&.\&.\&'\fP |
|
667 .fi |
|
668 .nf |
|
669 \f3\fP |
|
670 .fi |
|
671 .sp |
|
672 |
|
673 |
|
674 When the compiler encounters a \f3varargs\fR method, it translates the \f3varargs\fR formal parameter into an array\&. In the method \f3ClassWithVarargsMethod\&.varargsMethod\fR, the compiler translates the \f3varargs\fR formal parameter \f3String\&.\&.\&. s\fR to the formal parameter \f3String[] s\fR, an array, which matches the formal parameter of the method \f3ClassWithOverridingMethod\&.varargsMethod\fR\&. Consequently, this example compiles\&. |
|
675 .TP |
|
676 path |
|
677 Warns about invalid path elements and nonexistent path directories on the command line (with regard to the class path, the source path, and other paths)\&. Such warnings cannot be suppressed with the \f3@SuppressWarnings\fR annotation, for example: |
|
678 .sp |
|
679 .nf |
|
680 \f3javac \-Xlint:path \-classpath /nonexistentpath Example\&.java\fP |
|
681 .fi |
|
682 .nf |
|
683 \f3\fP |
|
684 .fi |
|
685 .sp |
|
686 |
|
687 .TP |
|
688 processing |
|
689 Warn about issues regarding annotation processing\&. The compiler generates this warning when you have a class that has an annotation, and you use an annotation processor that cannot handle that type of exception\&. For example, the following is a simple annotation processor: |
|
690 |
|
691 \fISource file AnnocProc\&.java\fR: |
|
692 .sp |
|
693 .nf |
|
694 \f3import java\&.util\&.*;\fP |
|
695 .fi |
|
696 .nf |
|
697 \f3import javax\&.annotation\&.processing\&.*;\fP |
|
698 .fi |
|
699 .nf |
|
700 \f3import javax\&.lang\&.model\&.*;\fP |
|
701 .fi |
|
702 .nf |
|
703 \f3import\&.javaz\&.lang\&.model\&.element\&.*;\fP |
|
704 .fi |
|
705 .nf |
|
706 \f3\fP |
|
707 .fi |
|
708 .nf |
|
709 \f3@SupportedAnnotationTypes("NotAnno")\fP |
|
710 .fi |
|
711 .nf |
|
712 \f3public class AnnoProc extends AbstractProcessor {\fP |
|
713 .fi |
|
714 .nf |
|
715 \f3 public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv){\fP |
|
716 .fi |
|
717 .nf |
|
718 \f3 return true;\fP |
|
719 .fi |
|
720 .nf |
|
721 \f3 }\fP |
|
722 .fi |
|
723 .nf |
|
724 \f3\fP |
|
725 .fi |
|
726 .nf |
|
727 \f3 public SourceVersion getSupportedSourceVersion() {\fP |
|
728 .fi |
|
729 .nf |
|
730 \f3 return SourceVersion\&.latest();\fP |
|
731 .fi |
|
732 .nf |
|
733 \f3 }\fP |
|
734 .fi |
|
735 .nf |
|
736 \f3}\fP |
|
737 .fi |
|
738 .nf |
|
739 \f3\fP |
|
740 .fi |
|
741 .sp |
|
742 |
|
743 |
|
744 \fISource file AnnosWithoutProcessors\&.java\fR: |
|
745 .sp |
|
746 .nf |
|
747 \f3@interface Anno { }\fP |
|
748 .fi |
|
749 .nf |
|
750 \f3\fP |
|
751 .fi |
|
752 .nf |
|
753 \f3@Anno\fP |
|
754 .fi |
|
755 .nf |
|
756 \f3class AnnosWithoutProcessors { }\fP |
|
757 .fi |
|
758 .nf |
|
759 \f3\fP |
|
760 .fi |
|
761 .sp |
|
762 |
|
763 |
|
764 The following commands compile the annotation processor \f3AnnoProc\fR, then run this annotation processor against the source file \f3AnnosWithoutProcessors\&.java\fR: |
|
765 .sp |
|
766 .nf |
|
767 \f3javac AnnoProc\&.java\fP |
|
768 .fi |
|
769 .nf |
|
770 \f3javac \-cp \&. \-Xlint:processing \-processor AnnoProc \-proc:only AnnosWithoutProcessors\&.java\fP |
|
771 .fi |
|
772 .nf |
|
773 \f3\fP |
|
774 .fi |
|
775 .sp |
|
776 |
|
777 |
|
778 When the compiler runs the annotation processor against the source file \f3AnnosWithoutProcessors\&.java\fR, it generates the following warning: |
|
779 .sp |
|
780 .nf |
|
781 \f3warning: [processing] No processor claimed any of these annotations: Anno\fP |
|
782 .fi |
|
783 .nf |
|
784 \f3\fP |
|
785 .fi |
|
786 .sp |
|
787 |
|
788 |
|
789 To resolve this issue, you can rename the annotation defined and used in the class \f3AnnosWithoutProcessors\fR from \f3Anno\fR to \f3NotAnno\fR\&. |
|
790 .TP |
|
791 rawtypes |
|
792 Warns about unchecked operations on raw types\&. The following statement generates a \f3rawtypes\fR warning: |
|
793 .sp |
|
794 .nf |
|
795 \f3void countElements(List l) { \&.\&.\&. }\fP |
|
796 .fi |
|
797 .nf |
|
798 \f3\fP |
|
799 .fi |
|
800 .sp |
|
801 |
|
802 |
|
803 The following example does not generate a \f3rawtypes\fR warning |
|
804 .sp |
|
805 .nf |
|
806 \f3void countElements(List<?> l) { \&.\&.\&. }\fP |
|
807 .fi |
|
808 .nf |
|
809 \f3\fP |
|
810 .fi |
|
811 .sp |
|
812 |
|
813 |
|
814 \f3List\fR is a raw type\&. However, \f3List<?>\fR is an unbounded wildcard parameterized type\&. Because \f3List\fR is a parameterized interface, always specify its type argument\&. In this example, the \f3List\fR formal argument is specified with an unbounded wildcard (\f3?\fR) as its formal type parameter, which means that the \f3countElements\fR method can accept any instantiation of the \f3List\fR interface\&. |
|
815 .TP |
|
816 Serial |
|
817 Warns about missing \f3serialVersionUID\fR definitions on serializable classes, for example: |
|
818 .sp |
|
819 .nf |
|
820 \f3public class PersistentTime implements Serializable\fP |
|
821 .fi |
|
822 .nf |
|
823 \f3{\fP |
|
824 .fi |
|
825 .nf |
|
826 \f3 private Date time;\fP |
|
827 .fi |
|
828 .nf |
|
829 \f3\fP |
|
830 .fi |
|
831 .nf |
|
832 \f3 public PersistentTime() {\fP |
|
833 .fi |
|
834 .nf |
|
835 \f3 time = Calendar\&.getInstance()\&.getTime();\fP |
|
836 .fi |
|
837 .nf |
|
838 \f3 }\fP |
|
839 .fi |
|
840 .nf |
|
841 \f3\fP |
|
842 .fi |
|
843 .nf |
|
844 \f3 public Date getTime() {\fP |
|
845 .fi |
|
846 .nf |
|
847 \f3 return time;\fP |
|
848 .fi |
|
849 .nf |
|
850 \f3 }\fP |
|
851 .fi |
|
852 .nf |
|
853 \f3}\fP |
|
854 .fi |
|
855 .nf |
|
856 \f3\fP |
|
857 .fi |
|
858 .sp |
|
859 |
|
860 |
|
861 The compiler generates the following warning: |
|
862 .sp |
|
863 .nf |
|
864 \f3warning: [serial] serializable class PersistentTime has no definition of\fP |
|
865 .fi |
|
866 .nf |
|
867 \f3serialVersionUID\fP |
|
868 .fi |
|
869 .nf |
|
870 \f3\fP |
|
871 .fi |
|
872 .sp |
|
873 |
|
874 |
|
875 If a serializable class does not explicitly declare a field named \f3serialVersionUID\fR, then the serialization runtime environment calculates a default \f3serialVersionUID\fR value for that class based on various aspects of the class, as described in the Java Object Serialization Specification\&. However, it is strongly recommended that all serializable classes explicitly declare \f3serialVersionUID\fR values because the default process of computing \f3serialVersionUID\fR vales is highly sensitive to class details that can vary depending on compiler implementations, and as a result, might cause an unexpected \f3InvalidClassExceptions\fR during deserialization\&. To guarantee a consistent \f3serialVersionUID\fR value across different Java compiler implementations, a serializable class must declare an explicit \f3serialVersionUID\fR value\&. |
|
876 .TP |
|
877 static |
|
878 Warns about issues relating to the use of statics, for example: |
|
879 .sp |
|
880 .nf |
|
881 \f3class XLintStatic {\fP |
|
882 .fi |
|
883 .nf |
|
884 \f3 static void m1() { }\fP |
|
885 .fi |
|
886 .nf |
|
887 \f3 void m2() { this\&.m1(); }\fP |
|
888 .fi |
|
889 .nf |
|
890 \f3}\fP |
|
891 .fi |
|
892 .nf |
|
893 \f3\fP |
|
894 .fi |
|
895 .sp |
|
896 |
|
897 |
|
898 The compiler generates the following warning: |
|
899 .sp |
|
900 .nf |
|
901 \f3warning: [static] static method should be qualified by type name, \fP |
|
902 .fi |
|
903 .nf |
|
904 \f3XLintStatic, instead of by an expression\fP |
|
905 .fi |
|
906 .nf |
|
907 \f3\fP |
|
908 .fi |
|
909 .sp |
|
910 |
|
911 |
|
912 To resolve this issue, you can call the \f3static\fR method \f3m1\fR as follows: |
|
913 .sp |
|
914 .nf |
|
915 \f3XLintStatic\&.m1();\fP |
|
916 .fi |
|
917 .nf |
|
918 \f3\fP |
|
919 .fi |
|
920 .sp |
|
921 |
|
922 |
|
923 Alternately, you can remove the \f3static\fR keyword from the declaration of the method \f3m1\fR\&. |
|
924 .TP |
|
925 try |
|
926 Warns about issues relating to use of \f3try\fR blocks, including try-with-resources statements\&. For example, a warning is generated for the following statement because the resource \f3ac\fR declared in the \f3try\fR block is not used: |
|
927 .sp |
|
928 .nf |
|
929 \f3try ( AutoCloseable ac = getResource() ) { // do nothing}\fP |
|
930 .fi |
|
931 .nf |
|
932 \f3\fP |
|
933 .fi |
|
934 .sp |
|
935 |
|
936 .TP |
|
937 unchecked |
|
938 Gives more detail for unchecked conversion warnings that are mandated by the Java Language Specification, for example: |
|
939 .sp |
|
940 .nf |
|
941 \f3List l = new ArrayList<Number>();\fP |
|
942 .fi |
|
943 .nf |
|
944 \f3List<String> ls = l; // unchecked warning\fP |
|
945 .fi |
|
946 .nf |
|
947 \f3\fP |
|
948 .fi |
|
949 .sp |
|
950 |
|
951 |
|
952 During type erasure, the types \f3ArrayList<Number>\fR and \f3List<String>\fR become \f3ArrayList\fR and \f3List\fR, respectively\&. |
|
953 |
|
954 The \f3ls\fR command has the parameterized type \f3List<String>\fR\&. When the \f3List\fR referenced by \f3l\fR is assigned to \f3ls\fR, the compiler generates an unchecked warning\&. At compile time, the compiler and JVM cannot determine whether \f3l\fR refers to a \f3List<String>\fR type\&. In this case, \f3l\fR does not refer to a \f3List<String>\fR type\&. As a result, heap pollution occurs\&. |
|
955 |
|
956 A heap pollution situation occurs when the \f3List\fR object \f3l\fR, whose static type is \f3List<Number>\fR, is assigned to another \f3List\fR object, \f3ls\fR, that has a different static type, \f3List<String>\fR\&. However, the compiler still allows this assignment\&. It must allow this assignment to preserve backward compatibility with releases of Java SE that do not support generics\&. Because of type erasure, \f3List<Number>\fR and \f3List<String>\fR both become \f3List\fR\&. Consequently, the compiler allows the assignment of the object \f3l\fR\f3,\fR which has a raw type of \f3List\fR, to the object \f3ls\fR\&. |
|
957 .TP |
|
958 varargs |
|
959 Warns about unsafe usages of variable arguments (\f3varargs\fR) methods, in particular, those that contain non-reifiable arguments, for example: |
|
960 .sp |
|
961 .nf |
|
962 \f3public class ArrayBuilder {\fP |
|
963 .fi |
|
964 .nf |
|
965 \f3 public static <T> void addToList (List<T> listArg, T\&.\&.\&. elements) {\fP |
|
966 .fi |
|
967 .nf |
|
968 \f3 for (T x : elements) {\fP |
|
969 .fi |
|
970 .nf |
|
971 \f3 listArg\&.add(x);\fP |
|
972 .fi |
|
973 .nf |
|
974 \f3 }\fP |
|
975 .fi |
|
976 .nf |
|
977 \f3 }\fP |
|
978 .fi |
|
979 .nf |
|
980 \f3}\fP |
|
981 .fi |
|
982 .nf |
|
983 \f3\fP |
|
984 .fi |
|
985 .sp |
|
986 |
|
987 |
|
988 \fINote:\fR A non-reifiable type is a type whose type information is not fully available at runtime\&. |
|
989 |
|
990 The compiler generates the following warning for the definition of the method \f3ArrayBuilder\&.addToList\fR |
|
991 .sp |
|
992 .nf |
|
993 \f3warning: [varargs] Possible heap pollution from parameterized vararg type T\fP |
|
994 .fi |
|
995 .nf |
|
996 \f3\fP |
|
997 .fi |
|
998 .sp |
|
999 |
|
1000 |
|
1001 When the compiler encounters a varargs method, it translates the \f3varargs\fR formal parameter into an array\&. However, the Java programming language does not permit the creation of arrays of parameterized types\&. In the method \f3ArrayBuilder\&.addToList\fR, the compiler translates the \f3varargs\fR formal parameter \f3T\&.\&.\&.\fR elements to the formal parameter \f3T[]\fR elements, an array\&. However, because of type erasure, the compiler converts the \f3varargs\fR formal parameter to \f3Object[]\fR elements\&. Consequently, there is a possibility of heap pollution\&. |
|
1002 .SH COMMAND-LINE\ ARGUMENT\ FILES |
|
1003 To shorten or simplify the \f3javac\fR command, you can specify one or more files that contain arguments to the \f3javac\fR command (except \f3-J\fR options)\&. This enables you to create \f3javac\fR commands of any length on any operating system\&. |
|
1004 .PP |
|
1005 An argument file can include \f3javac\fR options and source file names in any combination\&. The arguments within a file can be separated by spaces or new line characters\&. If a file name contains embedded spaces, then put the whole file name in double quotation marks\&. |
|
1006 .PP |
|
1007 File Names within an argument file are relative to the current directory, not the location of the argument file\&. Wild cards (*) are not allowed in these lists (such as for specifying \f3*\&.java\fR)\&. Use of the at sign (@) to recursively interpret files is not supported\&. The \f3-J\fR options are not supported because they are passed to the launcher, which does not support argument files\&. |
|
1008 .PP |
|
1009 When executing the \f3javac\fR command, pass in the path and name of each argument file with the at sign (@) leading character\&. When the \f3javac\fR command encounters an argument beginning with the at sign (@), it expands the contents of that file into the argument list\&. |
|
1010 .PP |
|
1011 \f3Example 1 Single Argument File\fR |
|
1012 .PP |
|
1013 You could use a single argument file named \f3argfile\fR to hold all \f3javac\fR arguments: |
|
1014 .sp |
|
1015 .nf |
|
1016 \f3javac @argfile\fP |
|
1017 .fi |
|
1018 .nf |
|
1019 \f3\fP |
|
1020 .fi |
|
1021 .sp |
|
1022 This argument file could contain the contents of both files shown in Example 2 |
|
1023 .PP |
|
1024 \f3Example 2 Two Argument Files\fR |
|
1025 .PP |
|
1026 You can create two argument files: one for the \f3javac\fR options and the other for the source file names\&. Note that the following lists have no line-continuation characters\&. |
|
1027 .PP |
|
1028 Create a file named options that contains the following: |
|
1029 .sp |
|
1030 .nf |
|
1031 \f3\-d classes\fP |
|
1032 .fi |
|
1033 .nf |
|
1034 \f3\-g\fP |
|
1035 .fi |
|
1036 .nf |
|
1037 \f3\-sourcepath /java/pubs/ws/1\&.3/src/share/classes\fP |
|
1038 .fi |
|
1039 .nf |
|
1040 \f3\fP |
|
1041 .fi |
|
1042 .sp |
|
1043 Create a file named classes that contains the following: |
|
1044 .sp |
|
1045 .nf |
|
1046 \f3MyClass1\&.java\fP |
|
1047 .fi |
|
1048 .nf |
|
1049 \f3MyClass2\&.java\fP |
|
1050 .fi |
|
1051 .nf |
|
1052 \f3MyClass3\&.java\fP |
|
1053 .fi |
|
1054 .nf |
|
1055 \f3\fP |
|
1056 .fi |
|
1057 .sp |
|
1058 Then, run the \f3javac\fR command as follows: |
|
1059 .sp |
|
1060 .nf |
|
1061 \f3javac @options @classes\fP |
|
1062 .fi |
|
1063 .nf |
|
1064 \f3\fP |
|
1065 .fi |
|
1066 .sp |
|
1067 \f3Example 3 Argument Files with Paths\fR |
|
1068 .PP |
|
1069 The argument files can have paths, but any file names inside the files are relative to the current working directory (not \f3path1\fR or \f3path2\fR): |
|
1070 .sp |
|
1071 .nf |
|
1072 \f3javac @path1/options @path2/classes\fP |
|
1073 .fi |
|
1074 .nf |
|
1075 \f3\fP |
|
1076 .fi |
|
1077 .sp |
|
1078 .SH ANNOTATION\ PROCESSING |
|
1079 The \f3javac\fR command provides direct support for annotation processing, superseding the need for the separate annotation processing command, \f3apt\fR\&. |
|
1080 .PP |
|
1081 The API for annotation processors is defined in the \f3javax\&.annotation\&.processing\fR and j\f3avax\&.lang\&.model\fR packages and subpackages\&. |
|
1082 .SS HOW\ ANNOTATION\ PROCESSING\ WORKS |
|
1083 Unless annotation processing is disabled with the \f3-proc:none\fR option, the compiler searches for any annotation processors that are available\&. The search path can be specified with the \f3-processorpath\fR option\&. If no path is specified, then the user class path is used\&. Processors are located by means of service provider-configuration files named \f3META-INF/services/javax\&.annotation\&.processing\fR\&.Processor on the search path\&. Such files should contain the names of any annotation processors to be used, listed one per line\&. Alternatively, processors can be specified explicitly, using the \f3-processor\fR option\&. |
|
1084 .PP |
|
1085 After scanning the source files and classes on the command line to determine what annotations are present, the compiler queries the processors to determine what annotations they process\&. When a match is found, the processor is called\&. A processor can claim the annotations it processes, in which case no further attempt is made to find any processors for those annotations\&. After all of the annotations are claimed, the compiler does not search for additional processors\&. |
|
1086 .PP |
|
1087 If any processors generate new source files, then another round of annotation processing occurs: Any newly generated source files are scanned, and the annotations processed as before\&. Any processors called on previous rounds are also called on all subsequent rounds\&. This continues until no new source files are generated\&. |
|
1088 .PP |
|
1089 After a round occurs where no new source files are generated, the annotation processors are called one last time, to give them a chance to complete any remaining work\&. Finally, unless the \f3-proc:only\fR option is used, the compiler compiles the original and all generated source files\&. |
|
1090 .SS IMPLICITLY\ LOADED\ SOURCE\ FILES |
|
1091 To compile a set of source files, the compiler might need to implicitly load additional source files\&. See Searching for Types\&. Such files are currently not subject to annotation processing\&. By default, the compiler gives a warning when annotation processing occurred and any implicitly loaded source files are compiled\&. The \f3-implicit\fR option provides a way to suppress the warning\&. |
|
1092 .SH SEARCHING\ FOR\ TYPES |
|
1093 To compile a source file, the compiler often needs information about a type, but the type definition is not in the source files specified on the command line\&. The compiler needs type information for every class or interface used, extended, or implemented in the source file\&. This includes classes and interfaces not explicitly mentioned in the source file, but that provide information through inheritance\&. |
|
1094 .PP |
|
1095 For example, when you create a subclass \f3java\&.applet\&.Applet\fR, you are also using the ancestor classes of \f3Applet\fR: \f3java\&.awt\&.Panel\fR, \f3java\&.awt\&.Container\fR, \f3java\&.awt\&.Component\fR, and \f3java\&.lang\&.Object\fR\&. |
|
1096 .PP |
|
1097 When the compiler needs type information, it searches for a source file or class file that defines the type\&. The compiler searches for class files first in the bootstrap and extension classes, then in the user class path (which by default is the current directory)\&. The user class path is defined by setting the \f3CLASSPATH\fR environment variable or by using the \f3-classpath\fR option\&. |
|
1098 .PP |
|
1099 If you set the \f3-sourcepath\fR option, then the compiler searches the indicated path for source files\&. Otherwise, the compiler searches the user class path for both class files and source files\&. |
|
1100 .PP |
|
1101 You can specify different bootstrap or extension classes with the \f3-bootclasspath\fR and the \f3-extdirs\fR options\&. See Cross-Compilation Options\&. |
|
1102 .PP |
|
1103 A successful type search may produce a class file, a source file, or both\&. If both are found, then you can use the \f3-Xprefer\fR option to instruct the compiler which to use\&. If \f3newer\fR is specified, then the compiler uses the newer of the two files\&. If \f3source\fR is specified, the compiler uses the source file\&. The default is \f3newer\fR\&. |
|
1104 .PP |
|
1105 If a type search finds a source file for a required type, either by itself, or as a result of the setting for the \f3-Xprefer\fR option, then the compiler reads the source file to get the information it needs\&. By default the compiler also compiles the source file\&. You can use the \f3-implicit\fR option to specify the behavior\&. If \f3none\fR is specified, then no class files are generated for the source file\&. If \f3class\fR is specified, then class files are generated for the source file\&. |
|
1106 .PP |
|
1107 The compiler might not discover the need for some type information until after annotation processing completes\&. When the type information is found in a source file and no \f3-implicit\fR option is specified, the compiler gives a warning that the file is being compiled without being subject to annotation processing\&. To disable the warning, either specify the file on the command line (so that it will be subject to annotation processing) or use the \f3-implicit\fR option to specify whether or not class files should be generated for such source files\&. |
|
1108 .SH PROGRAMMATIC\ INTERFACE |
|
1109 The \f3javac\fR command supports the new Java Compiler API defined by the classes and interfaces in the \f3javax\&.tools\fR package\&. |
|
1110 .SS EXAMPLE |
|
1111 To compile as though providing command-line arguments, use the following syntax: |
|
1112 .sp |
|
1113 .nf |
|
1114 \f3JavaCompiler javac = ToolProvider\&.getSystemJavaCompiler();\fP |
|
1115 .fi |
|
1116 .nf |
|
1117 \f3JavaCompiler javac = ToolProvider\&.getSystemJavaCompiler();\fP |
|
1118 .fi |
|
1119 .nf |
|
1120 \f3\fP |
|
1121 .fi |
|
1122 .sp |
|
1123 The example writes diagnostics to the standard output stream and returns the exit code that \f3javac\fR would give when called from the command line\&. |
|
1124 .PP |
|
1125 You can use other methods in the \f3javax\&.tools\&.JavaCompiler\fR interface to handle diagnostics, control where files are read from and written to, and more\&. |
|
1126 .SS OLD\ INTERFACE |
|
1127 \fINote:\fR This API is retained for backward compatibility only\&. All new code should use the newer Java Compiler API\&. |
|
1128 .PP |
|
1129 The \f3com\&.sun\&.tools\&.javac\&.Main\fR class provides two static methods to call the compiler from a program: |
|
1130 .sp |
|
1131 .nf |
|
1132 \f3public static int compile(String[] args);\fP |
|
1133 .fi |
|
1134 .nf |
|
1135 \f3public static int compile(String[] args, PrintWriter out);\fP |
|
1136 .fi |
|
1137 .nf |
|
1138 \f3\fP |
|
1139 .fi |
|
1140 .sp |
|
1141 The \f3args\fR parameter represents any of the command-line arguments that would typically be passed to the compiler\&. |
|
1142 .PP |
|
1143 The \f3out\fR parameter indicates where the compiler diagnostic output is directed\&. |
|
1144 .PP |
|
1145 The \f3return\fR value is equivalent to the \f3exit\fR value from \f3javac\fR\&. |
|
1146 .PP |
|
1147 \fINote:\fR All other classes and methods found in a package with names that start with \f3com\&.sun\&.tools\&.javac\fR (subpackages of \f3com\&.sun\&.tools\&.javac\fR) are strictly internal and subject to change at any time\&. |
|
1148 .SH EXAMPLES |
|
1149 \f3Example 1 Compile a Simple Program\fR |
|
1150 .PP |
|
1151 This example shows how to compile the \f3Hello\&.java\fR source file in the greetings directory\&. The class defined in \f3Hello\&.java\fR is called \f3greetings\&.Hello\fR\&. The greetings directory is the package directory both for the source file and the class file and is underneath the current directory\&. This makes it possible to use the default user class path\&. It also makes it unnecessary to specify a separate destination directory with the \f3-d\fR option\&. |
|
1152 .PP |
|
1153 The source code in \f3Hello\&.java\fR: |
|
1154 .sp |
|
1155 .nf |
|
1156 \f3package greetings;\fP |
|
1157 .fi |
|
1158 .nf |
|
1159 \f3\fP |
|
1160 .fi |
|
1161 .nf |
|
1162 \f3public class Hello {\fP |
|
1163 .fi |
|
1164 .nf |
|
1165 \f3 public static void main(String[] args) {\fP |
|
1166 .fi |
|
1167 .nf |
|
1168 \f3 for (int i=0; i < args\&.length; i++) {\fP |
|
1169 .fi |
|
1170 .nf |
|
1171 \f3 System\&.out\&.println("Hello " + args[i]);\fP |
|
1172 .fi |
|
1173 .nf |
|
1174 \f3 }\fP |
|
1175 .fi |
|
1176 .nf |
|
1177 \f3 }\fP |
|
1178 .fi |
|
1179 .nf |
|
1180 \f3}\fP |
|
1181 .fi |
|
1182 .nf |
|
1183 \f3\fP |
|
1184 .fi |
|
1185 .sp |
|
1186 Compile greetings\&.Hello: |
|
1187 .sp |
|
1188 .nf |
|
1189 \f3javac greetings/Hello\&.java\fP |
|
1190 .fi |
|
1191 .nf |
|
1192 \f3\fP |
|
1193 .fi |
|
1194 .sp |
|
1195 Run \f3greetings\&.Hello\fR: |
|
1196 .sp |
|
1197 .nf |
|
1198 \f3java greetings\&.Hello World Universe Everyone\fP |
|
1199 .fi |
|
1200 .nf |
|
1201 \f3Hello World\fP |
|
1202 .fi |
|
1203 .nf |
|
1204 \f3Hello Universe\fP |
|
1205 .fi |
|
1206 .nf |
|
1207 \f3Hello Everyone\fP |
|
1208 .fi |
|
1209 .nf |
|
1210 \f3\fP |
|
1211 .fi |
|
1212 .sp |
|
1213 \f3Example 2 Compile Multiple Source Files\fR |
|
1214 .PP |
|
1215 This example compiles the \f3Aloha\&.java\fR, \f3GutenTag\&.java\fR, \f3Hello\&.java\fR, and \f3Hi\&.java\fR source files in the \f3greetings\fR package\&. |
|
1216 .sp |
|
1217 .nf |
|
1218 \f3% javac greetings/*\&.java\fP |
|
1219 .fi |
|
1220 .nf |
|
1221 \f3% ls greetings\fP |
|
1222 .fi |
|
1223 .nf |
|
1224 \f3Aloha\&.class GutenTag\&.class Hello\&.class Hi\&.class\fP |
|
1225 .fi |
|
1226 .nf |
|
1227 \f3Aloha\&.java GutenTag\&.java Hello\&.java Hi\&.java\fP |
|
1228 .fi |
|
1229 .nf |
|
1230 \f3\fP |
|
1231 .fi |
|
1232 .sp |
|
1233 \f3Example 3 Specify a User Class Path\fR |
|
1234 .PP |
|
1235 After changing one of the source files in the previous example, recompile it: |
|
1236 .sp |
|
1237 .nf |
|
1238 \f3pwd\fP |
|
1239 .fi |
|
1240 .nf |
|
1241 \f3/examples\fP |
|
1242 .fi |
|
1243 .nf |
|
1244 \f3javac greetings/Hi\&.java\fP |
|
1245 .fi |
|
1246 .nf |
|
1247 \f3\fP |
|
1248 .fi |
|
1249 .sp |
|
1250 Because \f3greetings\&.Hi\fR refers to other classes in the \f3greetings\fR package, the compiler needs to find these other classes\&. The previous example works because the default user class path is the directory that contains the package directory\&. If you want to recompile this file without concern for which directory you are in, then add the examples directory to the user class path by setting \f3CLASSPATH\fR\&. This example uses the \f3-classpath\fR option\&. |
|
1251 .sp |
|
1252 .nf |
|
1253 \f3javac \-classpath /examples /examples/greetings/Hi\&.java\fP |
|
1254 .fi |
|
1255 .nf |
|
1256 \f3\fP |
|
1257 .fi |
|
1258 .sp |
|
1259 If you change \f3greetings\&.Hi\fR to use a banner utility, then that utility also needs to be accessible through the user class path\&. |
|
1260 .sp |
|
1261 .nf |
|
1262 \f3javac \-classpath /examples:/lib/Banners\&.jar \e\fP |
|
1263 .fi |
|
1264 .nf |
|
1265 \f3 /examples/greetings/Hi\&.java\fP |
|
1266 .fi |
|
1267 .nf |
|
1268 \f3\fP |
|
1269 .fi |
|
1270 .sp |
|
1271 To execute a class in the \f3greetings\fR package, the program needs access to the \f3greetings\fR package, and to the classes that the \f3greetings\fR classes use\&. |
|
1272 .sp |
|
1273 .nf |
|
1274 \f3java \-classpath /examples:/lib/Banners\&.jar greetings\&.Hi\fP |
|
1275 .fi |
|
1276 .nf |
|
1277 \f3\fP |
|
1278 .fi |
|
1279 .sp |
|
1280 \f3Example 4 Separate Source Files and Class Files\fR |
|
1281 .PP |
|
1282 The following example uses \f3javac\fR to compile code that runs on JVM 1\&.6\&. |
|
1283 .sp |
|
1284 .nf |
|
1285 \f3javac \-source 1\&.6 \-target 1\&.6 \-bootclasspath jdk1\&.6\&.0/lib/rt\&.jar \e \fP |
|
1286 .fi |
|
1287 .nf |
|
1288 \f3\-extdirs "" OldCode\&.java\fP |
|
1289 .fi |
|
1290 .nf |
|
1291 \f3\fP |
|
1292 .fi |
|
1293 .sp |
|
1294 The \f3-source 1\&.6\fR option specifies that release 1\&.6 (or 6) of the Java programming language be used to compile \f3OldCode\&.java\fR\&. The option \f3-target 1\&.6\fR option ensures that the generated class files are compatible with JVM 1\&.6\&. Note that in most cases, the value of the \f3-target\fR option is the value of the \f3-source\fR option; in this example, you can omit the \f3-target\fR option\&. |
|
1295 .PP |
|
1296 You must specify the \f3-bootclasspath\fR option to specify the correct version of the bootstrap classes (the \f3rt\&.jar\fR library)\&. If not, then the compiler generates a warning: |
|
1297 .sp |
|
1298 .nf |
|
1299 \f3javac \-source 1\&.6 OldCode\&.java\fP |
|
1300 .fi |
|
1301 .nf |
|
1302 \f3warning: [options] bootstrap class path not set in conjunction with \fP |
|
1303 .fi |
|
1304 .nf |
|
1305 \f3\-source 1\&.6\fP |
|
1306 .fi |
|
1307 .nf |
|
1308 \f3\fP |
|
1309 .fi |
|
1310 .sp |
|
1311 If you do not specify the correct version of bootstrap classes, then the compiler uses the old language rules (in this example, it uses version 1\&.6 of the Java programming language) combined with the new bootstrap classes, which can result in class files that do not work on the older platform (in this case, Java SE 6) because reference to nonexistent methods can get included\&. |
|
1312 .PP |
|
1313 \f3Example 5 Cross Compile\fR |
|
1314 .PP |
|
1315 This example uses \f3javac\fR to compile code that runs on JVM 1\&.6\&. |
|
1316 .sp |
|
1317 .nf |
|
1318 \f3javac \-source 1\&.6 \-target 1\&.6 \-bootclasspath jdk1\&.6\&.0/lib/rt\&.jar \e\fP |
|
1319 .fi |
|
1320 .nf |
|
1321 \f3 \-extdirs "" OldCode\&.java\fP |
|
1322 .fi |
|
1323 .nf |
|
1324 \f3\fP |
|
1325 .fi |
|
1326 .sp |
|
1327 The\f3-source 1\&.6\fR option specifies that release 1\&.6 (or 6) of the Java programming language to be used to compile OldCode\&.java\&. The \f3-target 1\&.6\fR option ensures that the generated class files are compatible with JVM 1\&.6\&. In most cases, the value of the \f3-target\fR is the value of \f3-source\fR\&. In this example, the \f3-target\fR option is omitted\&. |
|
1328 .PP |
|
1329 You must specify the \f3-bootclasspath\fR option to specify the correct version of the bootstrap classes (the \f3rt\&.jar\fR library)\&. If not, then the compiler generates a warning: |
|
1330 .sp |
|
1331 .nf |
|
1332 \f3javac \-source 1\&.6 OldCode\&.java\fP |
|
1333 .fi |
|
1334 .nf |
|
1335 \f3warning: [options] bootstrap class path not set in conjunction with \-source 1\&.6\fP |
|
1336 .fi |
|
1337 .nf |
|
1338 \f3\fP |
|
1339 .fi |
|
1340 .sp |
|
1341 If you do not specify the correct version of bootstrap classes, then the compiler uses the old language rules combined with the new bootstrap classes\&. This combination can result in class files that do not work on the older platform (in this case, Java SE 6) because reference to nonexistent methods can get included\&. In this example, the compiler uses release 1\&.6 of the Java programming language\&. |
|
1342 .SH SEE\ ALSO |
|
1343 .TP 0.2i |
|
1344 \(bu |
|
1345 java(1) |
|
1346 .TP 0.2i |
|
1347 \(bu |
|
1348 jdb(1) |
|
1349 .TP 0.2i |
|
1350 \(bu |
|
1351 javah(1) |
|
1352 .TP 0.2i |
|
1353 \(bu |
|
1354 javadoc(1) |
|
1355 .TP 0.2i |
|
1356 \(bu |
|
1357 jar(1) |
|
1358 .TP 0.2i |
|
1359 \(bu |
|
1360 jdb(1) |
56 .RE |
1361 .RE |
57 |
1362 .br |
58 .LP |
1363 'pl 8.5i |
59 .SH "DESCRIPTION" |
1364 'bp |
60 .LP |
|
61 .LP |
|
62 The \f3javac\fP tool reads class and interface definitions, written in the Java programming language, and compiles them into bytecode class files. It can also process annotations in Java source files and classes. |
|
63 .LP |
|
64 .LP |
|
65 There are two ways to pass source code file names to \f3javac\fP: |
|
66 .LP |
|
67 .RS 3 |
|
68 .TP 2 |
|
69 o |
|
70 For a small number of source files, simply list the file names on the command line. |
|
71 .TP 2 |
|
72 o |
|
73 For a large number of source files, list the file names in a file, separated by blanks or line breaks. Then use the list file name on the \f3javac\fP command line, preceded by an \f3@\fP character. |
|
74 .RE |
|
75 |
|
76 .LP |
|
77 .LP |
|
78 Source code file names must have \f2.java\fP suffixes, class file names must have \f2.class\fP suffixes, and both source and class files must have root names that identify the class. For example, a class called \f2MyClass\fP would be written in a source file called \f2MyClass.java\fP and compiled into a bytecode class file called \f2MyClass.class\fP. |
|
79 .LP |
|
80 .LP |
|
81 Inner class definitions produce additional class files. These class files have names combining the inner and outer class names, such as \f2MyClass$MyInnerClass.class\fP. |
|
82 .LP |
|
83 .LP |
|
84 You should arrange source files in a directory tree that reflects their package tree. For example, if you keep all your source files in \f3/workspace\fP, the source code for \f2com.mysoft.mypack.MyClass\fP should be in \f3/workspace/com/mysoft/mypack/MyClass.java\fP. |
|
85 .LP |
|
86 .LP |
|
87 By default, the compiler puts each class file in the same directory as its source file. You can specify a separate destination directory with \f3\-d\fP (see Options, below). |
|
88 .LP |
|
89 .SH "OPTIONS" |
|
90 .LP |
|
91 .LP |
|
92 The compiler has a set of standard options that are supported on the current development environment and will be supported in future releases. An additional set of non\-standard options are specific to the current virtual machine and compiler implementations and are subject to change in the future. Non\-standard options begin with \f3\-X\fP. |
|
93 .LP |
|
94 .SS |
|
95 Standard Options |
|
96 .LP |
|
97 .RS 3 |
|
98 .TP 3 |
|
99 \-Akey[=value] |
|
100 Options to pass to annotation processors. These are not interpreted by javac directly, but are made available for use by individual processors. \f2key\fP should be one or more identifiers separated by ".". |
|
101 .TP 3 |
|
102 \-cp path or \-classpath path |
|
103 Specify where to find user class files, and (optionally) annotation processors and source files. This class path overrides the user class path in the \f3CLASSPATH\fP environment variable. If neither \f3CLASSPATH\fP, \f3\-cp\fP nor \f3\-classpath\fP is specified, the user class path consists of the current directory. See Setting the Class Path for more details. |
|
104 .br |
|
105 .br |
|
106 >If the \f3\-sourcepath\fP option is not specified, the user class path is also searched for source files. |
|
107 .br |
|
108 .br |
|
109 If the \f3\-processorpath\fP option is not specified, the class path is also searched for annotation processors. |
|
110 .TP 3 |
|
111 \-Djava.ext.dirs=directories |
|
112 Override the location of installed extensions. |
|
113 .TP 3 |
|
114 \-Djava.endorsed.dirs=directories |
|
115 Override the location of endorsed standards path. |
|
116 .TP 3 |
|
117 \-d directory |
|
118 Set the destination directory for class files. The directory must already exist; \f3javac\fP will not create it. If a class is part of a package, \f3javac\fP puts the class file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify \f3\-d /home/myclasses\fP and the class is called \f2com.mypackage.MyClass\fP, then the class file is called \f2/home/myclasses/com/mypackage/MyClass.class\fP. |
|
119 .br |
|
120 .br |
|
121 If \f3\-d\fP is not specified, \f3javac\fP puts each class files in the same directory as the source file from which it was generated. |
|
122 .br |
|
123 .br |
|
124 \f3Note:\fP The directory specified by \f3\-d\fP is not automatically added to your user class path. |
|
125 .TP 3 |
|
126 \-deprecation |
|
127 Show a description of each use or override of a deprecated member or class. Without \f3\-deprecation\fP, \f3javac\fP shows a summary of the source files that use or override deprecated members or classes. \f3\-deprecation\fP is shorthand for \f3\-Xlint:deprecation\fP. |
|
128 .TP 3 |
|
129 \-encoding encoding |
|
130 Set the source file encoding name, such as \f2EUC\-JP and UTF\-8\fP. If \f3\-encoding\fP is not specified, the platform default converter is used. |
|
131 .TP 3 |
|
132 \-endorseddirs directories |
|
133 Override the location of endorsed standards path. |
|
134 .TP 3 |
|
135 \-extdirs directories |
|
136 Overrides the location of the \f2ext\fP directory. The \f2directories\fP variable is a colon\-separated list of directories. Each JAR archive in the specified directories is searched for class files. All JAR archives found are automatically part of the class path. |
|
137 .br |
|
138 .br |
|
139 If you are cross\-compiling (compiling classes against bootstrap and extension classes of a different Java platform implementation), this option specifies the directories that contain the extension classes. See Cross\-Compilation Options for more information. |
|
140 .TP 3 |
|
141 \-g |
|
142 Generate all debugging information, including local variables. By default, only line number and source file information is generated. |
|
143 .TP 3 |
|
144 \-g:none |
|
145 Do not generate any debugging information. |
|
146 .TP 3 |
|
147 \-g:{keyword list} |
|
148 Generate only some kinds of debugging information, specified by a comma separated list of keywords. Valid keywords are: |
|
149 .RS 3 |
|
150 .TP 3 |
|
151 source |
|
152 Source file debugging information |
|
153 .TP 3 |
|
154 lines |
|
155 Line number debugging information |
|
156 .TP 3 |
|
157 vars |
|
158 Local variable debugging information |
|
159 .RE |
|
160 .TP 3 |
|
161 \-help |
|
162 Print a synopsis of standard options. |
|
163 .TP 3 |
|
164 \-implicit:{class,none} |
|
165 Controls the generation of class files for implicitly loaded source files. To automatically generate class files, use \f3\-implicit:class\fP. To suppress class file generation, use \f3\-implicit:none\fP. If this option is not specified, the default is to automatically generate class files. In this case, the compiler will issue a warning if any such class files are generated when also doing annotation processing. The warning will not be issued if this option is set explicitly. See Searching For Types. |
|
166 .TP 3 |
|
167 \-Joption |
|
168 Pass \f2option\fP to the \f3java\fP launcher called by \f3javac\fP. For example, \f3\-J\-Xms48m\fP sets the startup memory to 48 megabytes. It is a common convention for \f3\-J\fP to pass options to the underlying VM executing applications written in Java. |
|
169 .br |
|
170 .br |
|
171 \f3Note:\fP \f3CLASSPATH\fP, \f3\-classpath\fP, \f3\-bootclasspath\fP, and \f3\-extdirs\fP do \f2not\fP specify the classes used to run \f3javac\fP. Fiddling with the implementation of the compiler in this way is usually pointless and always risky. If you do need to do this, use the \f3\-J\fP option to pass through options to the underlying \f3java\fP launcher. |
|
172 .TP 3 |
|
173 \-nowarn |
|
174 Disable warning messages. This has the same meaning as \f3\-Xlint:none\fP. |
|
175 .TP 3 |
|
176 \-proc: {none,only} |
|
177 Controls whether annotation processing and/or compilation is done. \f3\-proc:none\fP means that compilation takes place without annotation processing. \f3\-proc:only\fP means that only annotation processing is done, without any subsequent compilation. |
|
178 .TP 3 |
|
179 \-processor class1[,class2,class3...] |
|
180 Names of the annotation processors to run. This bypasses the default discovery process. |
|
181 .TP 3 |
|
182 \-processorpath path |
|
183 Specify where to find annotation processors; if this option is not used, the class path will be searched for processors. |
|
184 .TP 3 |
|
185 \-s dir |
|
186 Specify the directory where to place generated source files. The directory must already exist; \f3javac\fP will not create it. If a class is part of a package, the compiler puts the source file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify \f3\-s /home/mysrc\fP and the class is called \f2com.mypackage.MyClass\fP, then the source file will be placed in \f2/home/mysrc/com/mypackage/MyClass.java\fP. |
|
187 .TP 3 |
|
188 \-source release |
|
189 Specifies the version of source code accepted. The following values for \f2release\fP are allowed: |
|
190 .RS 3 |
|
191 .TP 3 |
|
192 1.3 |
|
193 The compiler does \f2not\fP support assertions, generics, or other language features introduced after JDK 1.3. |
|
194 .TP 3 |
|
195 1.4 |
|
196 The compiler accepts code containing assertions, which were introduced in JDK 1.4. |
|
197 .TP 3 |
|
198 1.5 |
|
199 The compiler accepts code containing generics and other language features introduced in JDK 5. |
|
200 .TP 3 |
|
201 5 |
|
202 Synonym for 1.5. |
|
203 .TP 3 |
|
204 1.6 |
|
205 This is the default value. No language changes were introduced in Java SE 6. However, encoding errors in source files are now reported as errors, instead of warnings, as previously. |
|
206 .TP 3 |
|
207 6 |
|
208 Synonym for 1.6. |
|
209 .TP 3 |
|
210 1.7 |
|
211 The compiler accepts code with features introduced in JDK 7. |
|
212 .TP 3 |
|
213 7 |
|
214 Synonym for 1.7. |
|
215 .RE |
|
216 .TP 3 |
|
217 \-sourcepath sourcepath |
|
218 Specify the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by colons (\f3:\fP) and can be directories, JAR archives, or ZIP archives. If packages are used, the local path name within the directory or archive must reflect the package name. |
|
219 .br |
|
220 .br |
|
221 \f3Note:\fP Classes found through the class path may be subject to automatic recompilation if their sources are also found. See Searching For Types. |
|
222 .TP 3 |
|
223 \-verbose |
|
224 Verbose output. This includes information about each class loaded and each source file compiled. |
|
225 .TP 3 |
|
226 \-version |
|
227 Print version information. |
|
228 .TP 3 |
|
229 \-Werror |
|
230 Terminate compilation if warnings occur. |
|
231 .TP 3 |
|
232 \-X |
|
233 Display information about non\-standard options and exit. |
|
234 .RE |
|
235 |
|
236 .LP |
|
237 .SS |
|
238 Cross\-Compilation Options |
|
239 .LP |
|
240 .LP |
|
241 By default, classes are compiled against the bootstrap and extension classes of the platform that \f3javac\fP shipped with. But \f3javac\fP also supports \f2cross\-compiling\fP, where classes are compiled against a bootstrap and extension classes of a different Java platform implementation. It is important to use \f3\-bootclasspath\fP and \f3\-extdirs\fP when cross\-compiling; see Cross\-Compilation Example below. |
|
242 .LP |
|
243 .RS 3 |
|
244 .TP 3 |
|
245 \-target version |
|
246 Generate class files that target a specified version of the VM. Class files will run on the specified target and on later versions, but not on earlier versions of the VM. Valid targets are \f31.1\fP \f31.2\fP \f31.3\fP \f31.4\fP \f31.5\fP (also \f35\fP) \f31.6\fP (also \f36\fP) and \f31.7\fP (also \f37\fP). |
|
247 .br |
|
248 .br |
|
249 The default for \f3\-target\fP depends on the value of \f3\-source\fP: |
|
250 .RS 3 |
|
251 .TP 2 |
|
252 o |
|
253 If \-source is \f3not specified\fP, the value of \-target is \f31.7\fP |
|
254 .TP 2 |
|
255 o |
|
256 If \-source is \f31.2\fP, the value of \-target is \f31.4\fP |
|
257 .TP 2 |
|
258 o |
|
259 If \-source is \f31.3\fP, the value of \-target is \f31.4\fP |
|
260 .TP 2 |
|
261 o |
|
262 For \f3all other values\fP of \-source, the value of \f3\-target\fP is the value of \f3\-source\fP. |
|
263 .RE |
|
264 .TP 3 |
|
265 \-bootclasspath bootclasspath |
|
266 Cross\-compile against the specified set of boot classes. As with the user class path, boot class path entries are separated by colons (\f3:\fP) and can be directories, JAR archives, or ZIP archives. |
|
267 .RE |
|
268 |
|
269 .LP |
|
270 .SS |
|
271 Non\-Standard Options |
|
272 .LP |
|
273 .RS 3 |
|
274 .TP 3 |
|
275 \-Xbootclasspath/p:path |
|
276 Prepend to the bootstrap class path. |
|
277 .TP 3 |
|
278 \-Xbootclasspath/a:path |
|
279 Append to the bootstrap class path. |
|
280 .TP 3 |
|
281 \-Xbootclasspath/:path |
|
282 Override location of bootstrap class files. |
|
283 .TP 3 |
|
284 \-Xlint |
|
285 Enable all recommended warnings. In this release, enabling all available warnings is recommended. |
|
286 .TP 3 |
|
287 \-Xlint:all |
|
288 Enable all recommended warnings. In this release, enabling all available warnings is recommended. |
|
289 .TP 3 |
|
290 \-Xlint:none |
|
291 Disable all warnings. |
|
292 .TP 3 |
|
293 \-Xlint:name |
|
294 Enable warning \f2name\fP. See the section Warnings That Can Be Enabled or Disabled with \-Xlint Option for a list of warnings you can enable with this option. |
|
295 .TP 3 |
|
296 \-Xlint:\-name |
|
297 Disable warning \f2name\fP. See the section Warnings That Can Be Enabled or Disabled with \-Xlint Option for a list of warnings you can disable with this option. |
|
298 .TP 3 |
|
299 \-Xmaxerrs number |
|
300 Set the maximum number of errors to print. |
|
301 .TP 3 |
|
302 \-Xmaxwarns number |
|
303 Set the maximum number of warnings to print. |
|
304 .TP 3 |
|
305 \-Xstdout filename |
|
306 Send compiler messages to the named file. By default, compiler messages go to \f2System.err\fP. |
|
307 .TP 3 |
|
308 \-Xprefer:{newer,source} |
|
309 Specify which file to read when both a source file and class file are found for a type. (See Searching For Types). If \f2\-Xprefer:newer\fP is used, it reads the newer of the source or class file for a type (default). If the \f2\-Xprefer:source\fP option is used, it reads source file. Use \f2\-Xprefer:source\fP when you want to be sure that any annotation processors can access annotations declared with a retention policy of \f2SOURCE\fP. |
|
310 .TP 3 |
|
311 \-Xpkginfo:{always,legacy,nonempty} |
|
312 Specify handling of package\-info files |
|
313 .TP 3 |
|
314 \-Xprint |
|
315 Print out textual representation of specified types for debugging purposes; perform neither annotation processing nor compilation. The format of the output may change. |
|
316 .TP 3 |
|
317 \-XprintProcessorInfo |
|
318 Print information about which annotations a processor is asked to process. |
|
319 .TP 3 |
|
320 \-XprintRounds |
|
321 Print information about initial and subsequent annotation processing rounds. |
|
322 .RE |
|
323 |
|
324 .LP |
|
325 .SS |
|
326 Warnings That Can Be Enabled or Disabled with \-Xlint Option |
|
327 .LP |
|
328 .LP |
|
329 Enable warning \f2name\fP with the option \f3\-Xlint:\fP\f2name\fP, where \f2name\fP is one of the following warning names. Similarly, you can disable warning \f2name\fP with the option \f3\-Xlint:\-\fP\f2name\fP: |
|
330 .LP |
|
331 .RS 3 |
|
332 .TP 3 |
|
333 cast |
|
334 Warn about unnecessary and redundant casts. For example: |
|
335 .nf |
|
336 \f3 |
|
337 .fl |
|
338 String s = (String)"Hello!" |
|
339 .fl |
|
340 \fP |
|
341 .fi |
|
342 .TP 3 |
|
343 classfile |
|
344 Warn about issues related to classfile contents. |
|
345 .TP 3 |
|
346 deprecation |
|
347 Warn about use of deprecated items. For example: |
|
348 .nf |
|
349 \f3 |
|
350 .fl |
|
351 java.util.Date myDate = new java.util.Date(); |
|
352 .fl |
|
353 int currentDay = myDate.getDay(); |
|
354 .fl |
|
355 \fP |
|
356 .fi |
|
357 The method \f2java.util.Date.getDay\fP has been deprecated since JDK 1.1. |
|
358 .TP 3 |
|
359 dep\-ann |
|
360 Warn about items that are documented with an \f2@deprecated\fP Javadoc comment, but do not have a \f2@Deprecated\fP annotation. For example: |
|
361 .nf |
|
362 \f3 |
|
363 .fl |
|
364 /** |
|
365 .fl |
|
366 * @deprecated As of Java SE 7, replaced by {@link #newMethod()} |
|
367 .fl |
|
368 */ |
|
369 .fl |
|
370 |
|
371 .fl |
|
372 public static void deprecatedMethood() { } |
|
373 .fl |
|
374 |
|
375 .fl |
|
376 public static void newMethod() { } |
|
377 .fl |
|
378 \fP |
|
379 .fi |
|
380 .TP 3 |
|
381 divzero |
|
382 Warn about division by constant integer 0. For example: |
|
383 .nf |
|
384 \f3 |
|
385 .fl |
|
386 int divideByZero = 42 / 0; |
|
387 .fl |
|
388 \fP |
|
389 .fi |
|
390 .TP 3 |
|
391 empty |
|
392 Warn about empty statements after \f2if\fP statements. For example: |
|
393 .nf |
|
394 \f3 |
|
395 .fl |
|
396 class E { |
|
397 .fl |
|
398 void m() { |
|
399 .fl |
|
400 if (true) ; |
|
401 .fl |
|
402 } |
|
403 .fl |
|
404 } |
|
405 .fl |
|
406 \fP |
|
407 .fi |
|
408 .TP 3 |
|
409 fallthrough |
|
410 Check \f2switch\fP blocks for fall\-through cases and provide a warning message for any that are found. Fall\-through cases are cases in a \f2switch\fP block, other than the last case in the block, whose code does not include a \f2break\fP statement, allowing code execution to "fall through" from that case to the next case. For example, the code following the \f2case 1\fP label in this \f2switch\fP block does not end with a \f2break\fP statement: |
|
411 .nf |
|
412 \f3 |
|
413 .fl |
|
414 switch (x) { |
|
415 .fl |
|
416 case 1: |
|
417 .fl |
|
418 System.out.println("1"); |
|
419 .fl |
|
420 // No break statement here. |
|
421 .fl |
|
422 case 2: |
|
423 .fl |
|
424 System.out.println("2"); |
|
425 .fl |
|
426 } |
|
427 .fl |
|
428 \fP |
|
429 .fi |
|
430 If the \f2\-Xlint:fallthrough\fP flag were used when compiling this code, the compiler would emit a warning about "possible fall\-through into case," along with the line number of the case in question. |
|
431 .TP 3 |
|
432 finally |
|
433 Warn about \f2finally\fP clauses that cannot complete normally. For example: |
|
434 .nf |
|
435 \f3 |
|
436 .fl |
|
437 public static int m() { |
|
438 .fl |
|
439 try { |
|
440 .fl |
|
441 throw new NullPointerException(); |
|
442 .fl |
|
443 } catch (NullPointerException e) { |
|
444 .fl |
|
445 System.err.println("Caught NullPointerException."); |
|
446 .fl |
|
447 return 1; |
|
448 .fl |
|
449 } finally { |
|
450 .fl |
|
451 return 0; |
|
452 .fl |
|
453 } |
|
454 .fl |
|
455 } |
|
456 .fl |
|
457 \fP |
|
458 .fi |
|
459 The compiler generates a warning for \f2finally\fP block in this example. When this method is called, it returns a value of \f20\fP, not \f21\fP. A \f2finally\fP block always executes when the \f2try\fP block exits. In this example, if control is transferred to the \f2catch\fP, then the method exits. However, the \f2finally\fP block must be executed, so it is executed, even though control has already been transferred outside the method. |
|
460 .TP 3 |
|
461 options |
|
462 Warn about issues relating to the use of command line options. See Cross\-Compilation Example for an example of this kind of warning. |
|
463 .TP 3 |
|
464 overrides |
|
465 Warn about issues regarding method overrides. For example, consider the following two classes: |
|
466 .nf |
|
467 \f3 |
|
468 .fl |
|
469 public class ClassWithVarargsMethod { |
|
470 .fl |
|
471 void varargsMethod(String... s) { } |
|
472 .fl |
|
473 } |
|
474 .fl |
|
475 \fP |
|
476 .fi |
|
477 .nf |
|
478 \f3 |
|
479 .fl |
|
480 public class ClassWithOverridingMethod extends ClassWithVarargsMethod { |
|
481 .fl |
|
482 @Override |
|
483 .fl |
|
484 void varargsMethod(String[] s) { } |
|
485 .fl |
|
486 } |
|
487 .fl |
|
488 \fP |
|
489 .fi |
|
490 The compiler generates a warning similar to the following: |
|
491 .br |
|
492 .br |
|
493 \f2warning: [override] varargsMethod(String[]) in ClassWithOverridingMethod overrides varargsMethod(String...) in ClassWithVarargsMethod; overriding method is missing '...'\fP |
|
494 .br |
|
495 .br |
|
496 When the compiler encounters a varargs method, it translates the varargs formal parameter into an array. In the method \f2ClassWithVarargsMethod.varargsMethod\fP, the compiler translates the varargs formal parameter \f2String... s\fP to the formal parameter \f2String[] s\fP, an array, which matches the formal parameter of the method \f2ClassWithOverridingMethod.varargsMethod\fP. Consequently, this example compiles. |
|
497 .TP 3 |
|
498 path |
|
499 Warn about invalid path elements and nonexistent path directories on the command line (with regards to the class path, the source path, and other paths). Such warnings cannot be suppressed with the \f2@SuppressWarnings\fP annotation. For example: |
|
500 .nf |
|
501 \f3 |
|
502 .fl |
|
503 javac \-Xlint:path \-classpath /nonexistentpath Example.java |
|
504 .fl |
|
505 \fP |
|
506 .fi |
|
507 .TP 3 |
|
508 processing |
|
509 Warn about issues regarding annotation processing. The compiler generates this warning if you have a class that has an annotation, and you use an annotation processor that cannot handle that type of exception. For example, the following is a simple annotation processor: |
|
510 .br |
|
511 .br |
|
512 \f3Source file \fP\f4AnnoProc.java\fP: |
|
513 .nf |
|
514 \f3 |
|
515 .fl |
|
516 import java.util.*; |
|
517 .fl |
|
518 import javax.annotation.processing.*; |
|
519 .fl |
|
520 import javax.lang.model.*; |
|
521 .fl |
|
522 import javax.lang.model.element.*; |
|
523 .fl |
|
524 |
|
525 .fl |
|
526 @SupportedAnnotationTypes("NotAnno") |
|
527 .fl |
|
528 public class AnnoProc extends AbstractProcessor { |
|
529 .fl |
|
530 public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { |
|
531 .fl |
|
532 return true; |
|
533 .fl |
|
534 } |
|
535 .fl |
|
536 |
|
537 .fl |
|
538 public SourceVersion getSupportedSourceVersion() { |
|
539 .fl |
|
540 return SourceVersion.latest(); |
|
541 .fl |
|
542 } |
|
543 .fl |
|
544 } |
|
545 .fl |
|
546 \fP |
|
547 .fi |
|
548 \f3Source file \fP\f4AnnosWithoutProcessors.java\fP\f3:\fP |
|
549 .nf |
|
550 \f3 |
|
551 .fl |
|
552 @interface Anno { } |
|
553 .fl |
|
554 |
|
555 .fl |
|
556 @Anno |
|
557 .fl |
|
558 class AnnosWithoutProcessors { } |
|
559 .fl |
|
560 \fP |
|
561 .fi |
|
562 The following commands compile the annotation processor \f2AnnoProc\fP, then run this annotation processor against the source file \f2AnnosWithoutProcessors.java\fP: |
|
563 .nf |
|
564 \f3 |
|
565 .fl |
|
566 % javac AnnoProc.java |
|
567 .fl |
|
568 % javac \-cp . \-Xlint:processing \-processor AnnoProc \-proc:only AnnosWithoutProcessors.java |
|
569 .fl |
|
570 \fP |
|
571 .fi |
|
572 When the compiler runs the annotation processor against the source file \f2AnnosWithoutProcessors.java\fP, it generates the following warning: |
|
573 .br |
|
574 .br |
|
575 \f2warning: [processing] No processor claimed any of these annotations: Anno\fP |
|
576 .br |
|
577 .br |
|
578 To resolve this issue, you can rename the annotation defined and used in the class \f2AnnosWithoutProcessors\fP from \f2Anno\fP to \f2NotAnno\fP. |
|
579 .TP 3 |
|
580 rawtypes |
|
581 Warn about unchecked operations on raw types. The following statement generates a \f2rawtypes\fP warning: |
|
582 .nf |
|
583 \f3 |
|
584 .fl |
|
585 void countElements(List l) { ... } |
|
586 .fl |
|
587 \fP |
|
588 .fi |
|
589 The following does not generate a \f2rawtypes\fP warning: |
|
590 .nf |
|
591 \f3 |
|
592 .fl |
|
593 void countElements(List<?> l) { ... } |
|
594 .fl |
|
595 \fP |
|
596 .fi |
|
597 \f2List\fP is a raw type. However, \f2List<?>\fP is a unbounded wildcard parameterized type. Because \f2List\fP is a parameterized interface, you should always specify its type argument. In this example, the \f2List\fP formal argument is specified with a unbounded wildcard (\f2?\fP) as its formal type parameter, which means that the \f2countElements\fP method can accept any instantiation of the \f2List\fP interface. |
|
598 .TP 3 |
|
599 serial |
|
600 Warn about missing \f2serialVersionUID\fP definitions on serializable classes. For example: |
|
601 .nf |
|
602 \f3 |
|
603 .fl |
|
604 public class PersistentTime implements Serializable |
|
605 .fl |
|
606 { |
|
607 .fl |
|
608 private Date time; |
|
609 .fl |
|
610 |
|
611 .fl |
|
612 public PersistentTime() { |
|
613 .fl |
|
614 time = Calendar.getInstance().getTime(); |
|
615 .fl |
|
616 } |
|
617 .fl |
|
618 |
|
619 .fl |
|
620 public Date getTime() { |
|
621 .fl |
|
622 return time; |
|
623 .fl |
|
624 } |
|
625 .fl |
|
626 } |
|
627 .fl |
|
628 \fP |
|
629 .fi |
|
630 The compiler generates the following warning: |
|
631 .br |
|
632 .br |
|
633 \f2warning: [serial] serializable class PersistentTime has no definition of serialVersionUID\fP |
|
634 .br |
|
635 .br |
|
636 If a serializable class does not explicitly declare a field named \f2serialVersionUID\fP, then the serialization runtime will calculate a default \f2serialVersionUID\fP value for that class based on various aspects of the class, as described in the Java Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare \f2serialVersionUID\fP values because the default process of computing \f2serialVersionUID\fP vales is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected \f2InvalidClassExceptions\fP during deserialization. Therefore, to guarantee a consistent \f2serialVersionUID\fP value across different Java compiler implementations, a serializable class must declare an explicit \f2serialVersionUID\fP value. |
|
637 .TP 3 |
|
638 static |
|
639 Warn about issues relating to use of statics. For example: |
|
640 .nf |
|
641 \f3 |
|
642 .fl |
|
643 class XLintStatic { |
|
644 .fl |
|
645 static void m1() { } |
|
646 .fl |
|
647 void m2() { this.m1(); } |
|
648 .fl |
|
649 } |
|
650 .fl |
|
651 \fP |
|
652 .fi |
|
653 The compiler generates the following warning: |
|
654 .nf |
|
655 \f3 |
|
656 .fl |
|
657 warning: [static] static method should be qualified by type name, XLintStatic, instead of by an expression |
|
658 .fl |
|
659 \fP |
|
660 .fi |
|
661 To resolve this issue, you can call the static method \f2m1\fP as follows: |
|
662 .nf |
|
663 \f3 |
|
664 .fl |
|
665 XLintStatic.m1(); |
|
666 .fl |
|
667 \fP |
|
668 .fi |
|
669 Alternatively, you can remove the \f2static\fP keyword from the declaration of the method \f2m1\fP. |
|
670 .TP 3 |
|
671 try |
|
672 Warn about issues relating to use of \f2try\fP blocks, including try\-with\-resources statements. For example, a warning is generated for the following statement because the resource \f2ac\fP declared in the \f2try\fP statement is not used: |
|
673 .nf |
|
674 \f3 |
|
675 .fl |
|
676 try ( AutoCloseable ac = getResource() ) { |
|
677 .fl |
|
678 // do nothing |
|
679 .fl |
|
680 } |
|
681 .fl |
|
682 \fP |
|
683 .fi |
|
684 .TP 3 |
|
685 unchecked |
|
686 Give more detail for unchecked conversion warnings that are mandated by the Java Language Specification. For example: |
|
687 .nf |
|
688 \f3 |
|
689 .fl |
|
690 List l = new ArrayList<Number>(); |
|
691 .fl |
|
692 List<String> ls = l; // unchecked warning |
|
693 .fl |
|
694 \fP |
|
695 .fi |
|
696 During type erasure, the types \f2ArrayList<Number>\fP and \f2List<String>\fP become \f2ArrayList\fP and \f2List\fP, respectively. |
|
697 .br |
|
698 .br |
|
699 The variable \f2ls\fP has the parameterized type \f2List<String>\fP. When the \f2List\fP referenced by \f2l\fP is assigned to \f2ls\fP, the compiler generates an unchecked warning; the compiler is unable to determine at compile time, and moreover knows that the JVM will not be able to determine at runtime, if \f2l\fP refers to a \f2List<String>\fP type; it does not. Consequently, heap pollution occurs. |
|
700 .br |
|
701 .br |
|
702 In detail, a heap pollution situation occurs when the \f2List\fP object \f2l\fP, whose static type is \f2List<Number>\fP, is assigned to another \f2List\fP object, \f2ls\fP, that has a different static type, \f2List<String>\fP. However, the compiler still allows this assignment. It must allow this assignment to preserve backwards compatibility with versions of Java SE that do not support generics. Because of type erasure, \f2List<Number>\fP and \f2List<String>\fP both become \f2List\fP. Consequently, the compiler allows the assignment of the object \f2l\fP, which has a raw type of \f2List\fP, to the object \f2ls\fP. |
|
703 .TP 3 |
|
704 varargs |
|
705 Warn about unsafe usages of variable arguments (varargs) methods, in particular, those that contain non\-reifiable arguments. For example: |
|
706 .nf |
|
707 \f3 |
|
708 .fl |
|
709 public class ArrayBuilder { |
|
710 .fl |
|
711 public static <T> void addToList (List<T> listArg, T... elements) { |
|
712 .fl |
|
713 for (T x : elements) { |
|
714 .fl |
|
715 listArg.add(x); |
|
716 .fl |
|
717 } |
|
718 .fl |
|
719 } |
|
720 .fl |
|
721 } |
|
722 .fl |
|
723 \fP |
|
724 .fi |
|
725 The compiler generates the following warning for the definition of the method \f2ArrayBuilder.addToList\fP: |
|
726 .nf |
|
727 \f3 |
|
728 .fl |
|
729 warning: [varargs] Possible heap pollution from parameterized vararg type T |
|
730 .fl |
|
731 \fP |
|
732 .fi |
|
733 When the compiler encounters a varargs method, it translates the varargs formal parameter into an array. However, the Java programming language does not permit the creation of arrays of parameterized types. In the method \f2ArrayBuilder.addToList\fP, the compiler translates the varargs formal parameter \f2T... elements\fP to the formal parameter \f2T[] elements\fP, an array. However, because of type erasure, the compiler converts the varargs formal parameter to \f2Object[] elements\fP. Consequently, there is a possibility of heap pollution. |
|
734 .RE |
|
735 |
|
736 .LP |
|
737 .SH "COMMAND LINE ARGUMENT FILES" |
|
738 .LP |
|
739 .LP |
|
740 To shorten or simplify the javac command line, you can specify one or more files that themselves contain arguments to the \f2javac\fP command (except \f2\-J\fP options). This enables you to create javac commands of any length on any operating system. |
|
741 .LP |
|
742 .LP |
|
743 An argument file can include javac options and source filenames in any combination. The arguments within a file can be space\-separated or newline\-separated. If a filename contains embedded spaces, put the whole filename in double quotes. |
|
744 .LP |
|
745 .LP |
|
746 Filenames within an argument file are relative to the current directory, not the location of the argument file. Wildcards (*) are not allowed in these lists (such as for specifying \f2*.java\fP). 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. |
|
747 .LP |
|
748 .LP |
|
749 When executing javac, pass in the path and name of each argument file with the '\f2@\fP' leading character. When javac encounters an argument beginning with the character `\f2@\fP', it expands the contents of that file into the argument list. |
|
750 .LP |
|
751 .SS |
|
752 Example \- Single Arg File |
|
753 .LP |
|
754 .LP |
|
755 You could use a single argument file named "\f2argfile\fP" to hold all javac arguments: |
|
756 .LP |
|
757 .nf |
|
758 \f3 |
|
759 .fl |
|
760 % \fP\f3javac @argfile\fP |
|
761 .fl |
|
762 .fi |
|
763 |
|
764 .LP |
|
765 .LP |
|
766 This argument file could contain the contents of both files shown in the next example. |
|
767 .LP |
|
768 .SS |
|
769 Example \- Two Arg Files |
|
770 .LP |
|
771 .LP |
|
772 You can create two argument files \-\- one for the javac options and the other for the source filenames: (Notice the following lists have no line\-continuation characters.) |
|
773 .LP |
|
774 .LP |
|
775 Create a file named "\f2options\fP" containing: |
|
776 .LP |
|
777 .nf |
|
778 \f3 |
|
779 .fl |
|
780 \-d classes |
|
781 .fl |
|
782 \-g |
|
783 .fl |
|
784 \-sourcepath /java/pubs/ws/1.3/src/share/classes |
|
785 .fl |
|
786 |
|
787 .fl |
|
788 \fP |
|
789 .fi |
|
790 |
|
791 .LP |
|
792 .LP |
|
793 Create a file named "\f2classes\fP" containing: |
|
794 .LP |
|
795 .nf |
|
796 \f3 |
|
797 .fl |
|
798 MyClass1.java |
|
799 .fl |
|
800 MyClass2.java |
|
801 .fl |
|
802 MyClass3.java |
|
803 .fl |
|
804 |
|
805 .fl |
|
806 \fP |
|
807 .fi |
|
808 |
|
809 .LP |
|
810 .LP |
|
811 You would then run \f3javac\fP with: |
|
812 .LP |
|
813 .nf |
|
814 \f3 |
|
815 .fl |
|
816 % \fP\f3javac @options @classes\fP |
|
817 .fl |
|
818 |
|
819 .fl |
|
820 .fi |
|
821 |
|
822 .LP |
|
823 .SS |
|
824 Example \- Arg Files with Paths |
|
825 .LP |
|
826 .LP |
|
827 The argument files can have paths, but any filenames inside the files are relative to the current working directory (not \f2path1\fP or \f2path2\fP): |
|
828 .LP |
|
829 .nf |
|
830 \f3 |
|
831 .fl |
|
832 % \fP\f3javac @path1/options @path2/classes\fP |
|
833 .fl |
|
834 .fi |
|
835 |
|
836 .LP |
|
837 .SH "ANNOTATION PROCESSING" |
|
838 .LP |
|
839 .LP |
|
840 \f3javac\fP provides direct support for annotation processing, superseding the need for the separate annotation processing tool, \f3apt\fP. |
|
841 .LP |
|
842 .LP |
|
843 The API for annotation processors is defined in the \f2javax.annotation.processing\fP and \f2javax.lang.model\fP packages and subpackages. |
|
844 .LP |
|
845 .SS |
|
846 Overview of annotation processing |
|
847 .LP |
|
848 .LP |
|
849 Unless annotation processing is disabled with the \f3\-proc:none\fP option, the compiler searches for any annotation processors that are available. The search path can be specified with the \f3\-processorpath\fP option; if it is not given, the user class path is used. Processors are located by means of service provider\-configuration files named \f2META\-INF/services/javax.annotation.processing.Processor\fP on the search path. Such files should contain the names of any annotation processors to be used, listed one per line. Alternatively, processors can be specified explicitly, using the \f3\-processor\fP option. |
|
850 .LP |
|
851 .LP |
|
852 After scanning the source files and classes on the command line to determine what annotations are present, the compiler queries the processors to determine what annotations they process. When a match is found, the processor will be invoked. A processor may "claim" the annotations it processes, in which case no further attempt is made to find any processors for those annotations. Once all annotations have been claimed, the compiler does not look for additional processors. |
|
853 .LP |
|
854 .LP |
|
855 If any processors generate any new source files, another round of annotation processing will occur: any newly generated source files will be scanned, and the annotations processed as before. Any processors invoked on previous rounds will also be invoked on all subsequent rounds. This continues until no new source files are generated. |
|
856 .LP |
|
857 .LP |
|
858 After a round occurs where no new source files are generated, the annotation processors will be invoked one last time, to give them a chance to complete any work they may need to do. Finally, unless the \f3\-proc:only\fP option is used, the compiler will compile the original and all the generated source files. |
|
859 .LP |
|
860 .SS |
|
861 Implicitly loaded source files |
|
862 .LP |
|
863 .LP |
|
864 To compile a set of source files, the compiler may need to implicitly load additional source files. (See Searching For Types). Such files are currently not subject to annotation processing. By default, the compiler will give a warning if annotation processing has occurred and any implicitly loaded source files are compiled. See the \-implicit option for ways to suppress the warning. |
|
865 .LP |
|
866 .SH "SEARCHING FOR TYPES" |
|
867 .LP |
|
868 .LP |
|
869 When compiling a source file, the compiler often needs information about a type whose definition did not appear in the source files given on the command line. The compiler needs type information for every class or interface used, extended, or implemented in the source file. This includes classes and interfaces not explicitly mentioned in the source file but which provide information through inheritance. |
|
870 .LP |
|
871 .LP |
|
872 For example, when you subclass \f3java.applet.Applet\fP, you are also using \f3Applet's\fP ancestor classes: \f3java.awt.Panel\fP, \f3java.awt.Container\fP, \f3java.awt.Component\fP, and \f3java.lang.Object\fP. |
|
873 .LP |
|
874 .LP |
|
875 When the compiler needs type information, it looks for a source file or class file which defines the type. The compiler searches for class files first in the bootstrap and extension classes, then in the user class path (which by default is the current directory). The user class path is defined by setting the \f3CLASSPATH\fP environment variable or by using the \f3\-classpath\fP command line option. (For details, see Setting the Class Path). |
|
876 .LP |
|
877 .LP |
|
878 If you set the \-sourcepath option, the compiler searches the indicated path for source files; otherwise the compiler searches the user class path for both class files and source files. |
|
879 .LP |
|
880 .LP |
|
881 You can specify different bootstrap or extension classes with the \f3\-bootclasspath\fP and \f3\-extdirs\fP options; see Cross\-Compilation Options below. |
|
882 .LP |
|
883 .LP |
|
884 A successful type search may produce a class file, a source file, or both. If both are found, you can use the \-Xprefer option to instruct the compiler which to use. If \f3newer\fP is given, the compiler will use the newer of the two files. If \f3source\fP is given, it will use the source file. The default is \f3newer\fP. |
|
885 .LP |
|
886 .LP |
|
887 If a type search finds a source file for a required type, either by itself, or as a result of the setting for \f3\-Xprefer\fP, the compiler will read the source file to get the information it needs. In addition, it will by default compile the source file as well. You can use the \-implicit option to specify the behavior. If \f3none\fP is given, no class files will be generated for the source file. If \f3class\fP is given, class files will be generated for the source file. |
|
888 .LP |
|
889 .LP |
|
890 The compiler may not discover the need for some type information until after annotation processing is complete. If the type information is found in a source file and no \f3\-implicit\fP option is given, the compiler will give a warning that the file is being compiled without being subject to annotation processing. To disable the warning, either specify the file on the command line (so that it will be subject to annotation processing) or use the \f3\-implicit\fP option to specify whether or not class files should be generated for such source files. |
|
891 .LP |
|
892 .SH "PROGRAMMATIC INTERFACE" |
|
893 .LP |
|
894 .LP |
|
895 \f3javac\fP supports the new Java Compiler API defined by the classes and interfaces in the \f2javax.tools\fP package. |
|
896 .LP |
|
897 .SS |
|
898 Example |
|
899 .LP |
|
900 .LP |
|
901 To perform a compilation using arguments as you would give on the command line, you can use the following: |
|
902 .LP |
|
903 .nf |
|
904 \f3 |
|
905 .fl |
|
906 JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); |
|
907 .fl |
|
908 int rc = javac.run(null, null, null, args); |
|
909 .fl |
|
910 \fP |
|
911 .fi |
|
912 |
|
913 .LP |
|
914 .LP |
|
915 This will write any diagnostics to the standard output stream, and return the exit code that \f3javac\fP would give when invoked from the command line. |
|
916 .LP |
|
917 .LP |
|
918 You can use other methods on the \f2javax.tools.JavaCompiler\fP interface to handle diagnostics, control where files are read from and written to, and so on. |
|
919 .LP |
|
920 .SS |
|
921 Old Interface |
|
922 .LP |
|
923 .LP |
|
924 \f3Note:\fP This API is retained for backwards compatibility only; all new code should use the Java Compiler API, described above. |
|
925 .LP |
|
926 .LP |
|
927 The \f2com.sun.tools.javac.Main\fP class provides two static methods to invoke the compiler from a program: |
|
928 .LP |
|
929 .nf |
|
930 \f3 |
|
931 .fl |
|
932 public static int compile(String[] args); |
|
933 .fl |
|
934 public static int compile(String[] args, PrintWriter out); |
|
935 .fl |
|
936 \fP |
|
937 .fi |
|
938 |
|
939 .LP |
|
940 .LP |
|
941 The \f2args\fP parameter represents any of the command line arguments that would normally be passed to the javac program and are outlined in the above Synopsis section. |
|
942 .LP |
|
943 .LP |
|
944 The \f2out\fP parameter indicates where the compiler's diagnostic output is directed. |
|
945 .LP |
|
946 .LP |
|
947 The return value is equivalent to the exit value from \f3javac\fP. |
|
948 .LP |
|
949 .LP |
|
950 Note that all \f3other\fP classes and methods found in a package whose name starts with \f2com.sun.tools.javac\fP (informally known as sub\-packages of \f2com.sun.tools.javac\fP) are strictly internal and subject to change at any time. |
|
951 .LP |
|
952 .SH "EXAMPLES" |
|
953 .LP |
|
954 .SS |
|
955 Compiling a Simple Program |
|
956 .LP |
|
957 .LP |
|
958 One source file, \f2Hello.java\fP, defines a class called \f3greetings.Hello\fP. The \f2greetings\fP directory is the package directory both for the source file and the class file and is off the current directory. This allows us to use the default user class path. It also makes it unnecessary to specify a separate destination directory with \f3\-d\fP. |
|
959 .LP |
|
960 .nf |
|
961 \f3 |
|
962 .fl |
|
963 % \fP\f3ls\fP |
|
964 .fl |
|
965 greetings/ |
|
966 .fl |
|
967 % \f3ls greetings\fP |
|
968 .fl |
|
969 Hello.java |
|
970 .fl |
|
971 % \f3cat greetings/Hello.java\fP |
|
972 .fl |
|
973 package greetings; |
|
974 .fl |
|
975 |
|
976 .fl |
|
977 public class Hello { |
|
978 .fl |
|
979 public static void main(String[] args) { |
|
980 .fl |
|
981 for (int i=0; i < args.length; i++) { |
|
982 .fl |
|
983 System.out.println("Hello " + args[i]); |
|
984 .fl |
|
985 } |
|
986 .fl |
|
987 } |
|
988 .fl |
|
989 } |
|
990 .fl |
|
991 % \f3javac greetings/Hello.java\fP |
|
992 .fl |
|
993 % \f3ls greetings\fP |
|
994 .fl |
|
995 Hello.class Hello.java |
|
996 .fl |
|
997 % \f3java greetings.Hello World Universe Everyone\fP |
|
998 .fl |
|
999 Hello World |
|
1000 .fl |
|
1001 Hello Universe |
|
1002 .fl |
|
1003 Hello Everyone |
|
1004 .fl |
|
1005 .fi |
|
1006 |
|
1007 .LP |
|
1008 .SS |
|
1009 Compiling Multiple Source Files |
|
1010 .LP |
|
1011 .LP |
|
1012 This example compiles all the source files in the package \f2greetings\fP. |
|
1013 .LP |
|
1014 .nf |
|
1015 \f3 |
|
1016 .fl |
|
1017 % \fP\f3ls\fP |
|
1018 .fl |
|
1019 greetings/ |
|
1020 .fl |
|
1021 % \f3ls greetings\fP |
|
1022 .fl |
|
1023 Aloha.java GutenTag.java Hello.java Hi.java |
|
1024 .fl |
|
1025 % \f3javac greetings/*.java\fP |
|
1026 .fl |
|
1027 % \f3ls greetings\fP |
|
1028 .fl |
|
1029 Aloha.class GutenTag.class Hello.class Hi.class |
|
1030 .fl |
|
1031 Aloha.java GutenTag.java Hello.java Hi.java |
|
1032 .fl |
|
1033 .fi |
|
1034 |
|
1035 .LP |
|
1036 .SS |
|
1037 Specifying a User Class Path |
|
1038 .LP |
|
1039 .LP |
|
1040 Having changed one of the source files in the previous example, we recompile it: |
|
1041 .LP |
|
1042 .nf |
|
1043 \f3 |
|
1044 .fl |
|
1045 % \fP\f3pwd\fP |
|
1046 .fl |
|
1047 /examples |
|
1048 .fl |
|
1049 % \f3javac greetings/Hi.java\fP |
|
1050 .fl |
|
1051 .fi |
|
1052 |
|
1053 .LP |
|
1054 .LP |
|
1055 Since \f2greetings.Hi\fP refers to other classes in the \f2greetings\fP package, the compiler needs to find these other classes. The example above works, because our default user class path happens to be the directory containing the package directory. But suppose we want to recompile this file and not worry about which directory we're in? Then we need to add \f2/examples\fP to the user class path. We can do this by setting \f3CLASSPATH\fP, but here we'll use the \f3\-classpath\fP option. |
|
1056 .LP |
|
1057 .nf |
|
1058 \f3 |
|
1059 .fl |
|
1060 % \fP\f3javac \-classpath /examples /examples/greetings/Hi.java\fP |
|
1061 .fl |
|
1062 .fi |
|
1063 |
|
1064 .LP |
|
1065 .LP |
|
1066 If we change \f2greetings.Hi\fP again, to use a banner utility, that utility also needs to be accessible through the user class path. |
|
1067 .LP |
|
1068 .nf |
|
1069 \f3 |
|
1070 .fl |
|
1071 % \fP\f3javac \-classpath /examples:/lib/Banners.jar \\ |
|
1072 .fl |
|
1073 /examples/greetings/Hi.java\fP |
|
1074 .fl |
|
1075 .fi |
|
1076 |
|
1077 .LP |
|
1078 .LP |
|
1079 To execute a class in \f2greetings\fP, we need access both to \f2greetings\fP and to the classes it uses. |
|
1080 .LP |
|
1081 .nf |
|
1082 \f3 |
|
1083 .fl |
|
1084 % \fP\f3java \-classpath /examples:/lib/Banners.jar greetings.Hi\fP |
|
1085 .fl |
|
1086 .fi |
|
1087 |
|
1088 .LP |
|
1089 .SS |
|
1090 Separating Source Files and Class Files |
|
1091 .LP |
|
1092 .LP |
|
1093 It often makes sense to keep source files and class files in separate directories, especially on large projects. We use \f3\-d\fP to indicate the separate class file destination. Since the source files are not in the user class path, we use \f3\-sourcepath\fP to help the compiler find them. |
|
1094 .LP |
|
1095 .nf |
|
1096 \f3 |
|
1097 .fl |
|
1098 % \fP\f3ls\fP |
|
1099 .fl |
|
1100 classes/ lib/ src/ |
|
1101 .fl |
|
1102 % \f3ls src\fP |
|
1103 .fl |
|
1104 farewells/ |
|
1105 .fl |
|
1106 % \f3ls src/farewells\fP |
|
1107 .fl |
|
1108 Base.java GoodBye.java |
|
1109 .fl |
|
1110 % \f3ls lib\fP |
|
1111 .fl |
|
1112 Banners.jar |
|
1113 .fl |
|
1114 % \f3ls classes\fP |
|
1115 .fl |
|
1116 % \f3javac \-sourcepath src \-classpath classes:lib/Banners.jar \\ |
|
1117 .fl |
|
1118 src/farewells/GoodBye.java \-d classes\fP |
|
1119 .fl |
|
1120 % \f3ls classes\fP |
|
1121 .fl |
|
1122 farewells/ |
|
1123 .fl |
|
1124 % \f3ls classes/farewells\fP |
|
1125 .fl |
|
1126 Base.class GoodBye.class |
|
1127 .fl |
|
1128 .fi |
|
1129 |
|
1130 .LP |
|
1131 .LP |
|
1132 \f3Note:\fP The compiler compiled \f2src/farewells/Base.java\fP, even though we didn't specify it on the command line. To trace automatic compiles, use the \f3\-verbose\fP option. |
|
1133 .LP |
|
1134 .SS |
|
1135 Cross\-Compilation Example |
|
1136 .LP |
|
1137 .LP |
|
1138 Here we use \f3javac\fP to compile code that will run on a 1.6 VM. |
|
1139 .LP |
|
1140 .nf |
|
1141 \f3 |
|
1142 .fl |
|
1143 % \fP\f3javac \-source 1.6 \-target 1.6 \-bootclasspath jdk1.6.0/lib/rt.jar \\ |
|
1144 .fl |
|
1145 \-extdirs "" OldCode.java\fP |
|
1146 .fl |
|
1147 .fi |
|
1148 |
|
1149 .LP |
|
1150 .LP |
|
1151 The \f2\-source 1.6\fP option specifies that version 1.6 (or 6) of the Java programming language be used to compile \f2OldCode.java\fP. The option \f3\-target 1.6\fP option ensures that the generated class files will be compatible with 1.6 VMs. Note that in most cases, the value of the \f3\-target\fP option is the value of the \f3\-source\fP option; in this example, you can omit the \f3\-target\fP option. |
|
1152 .LP |
|
1153 .LP |
|
1154 You must specify the \f3\-bootclasspath\fP option to specify the correct version of the bootstrap classes (the \f2rt.jar\fP library). If not, the compiler generates a warning: |
|
1155 .LP |
|
1156 .nf |
|
1157 \f3 |
|
1158 .fl |
|
1159 % \fP\f3javac \-source 1.6 OldCode.java\fP |
|
1160 .fl |
|
1161 warning: [options] bootstrap class path not set in conjunction with \-source 1.6 |
|
1162 .fl |
|
1163 .fi |
|
1164 |
|
1165 .LP |
|
1166 .LP |
|
1167 If you do not specify the correct version of bootstrap classes, the compiler will use the old language rules (in this example, it will use version 1.6 of the Java programming language) combined with the new bootstrap classes, which can result in class files that do not work on the older platform (in this case, Java SE 6) because reference to non\-existent methods can get included. |
|
1168 .LP |
|
1169 .SH "SEE ALSO" |
|
1170 .LP |
|
1171 .RS 3 |
|
1172 .TP 2 |
|
1173 o |
|
1174 .na |
|
1175 \f2The javac Guide\fP @ |
|
1176 .fi |
|
1177 http://download.oracle.com/javase/7/docs/technotes/guides/javac/index.html |
|
1178 .TP 2 |
|
1179 o |
|
1180 java(1) \- the Java Application Launcher |
|
1181 .TP 2 |
|
1182 o |
|
1183 jdb(1) \- Java Application Debugger |
|
1184 .TP 2 |
|
1185 o |
|
1186 javah(1) \- C Header and Stub File Generator |
|
1187 .TP 2 |
|
1188 o |
|
1189 javap(1) \- Class File Disassembler |
|
1190 .TP 2 |
|
1191 o |
|
1192 javadoc(1) \- API Documentation Generator |
|
1193 .TP 2 |
|
1194 o |
|
1195 jar(1) \- JAR Archive Tool |
|
1196 .TP 2 |
|
1197 o |
|
1198 .na |
|
1199 \f2The Java Extensions Framework\fP @ |
|
1200 .fi |
|
1201 http://download.oracle.com/javase/7/docs/technotes/guides/extensions/index.html |
|
1202 .RE |
|
1203 |
|
1204 .LP |
|
1205 |
|