jdk/src/linux/doc/man/javac.1
author michaelm
Thu, 13 Jan 2011 11:01:30 +0000
changeset 7980 3af394bb6f59
parent 5865 47da38a8c0f0
child 9573 c02ff5a7c67b
permissions -rw-r--r--
6896088: URLClassLoader.close() apparently not working for JAR URLs on Windows Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5865
47da38a8c0f0 6955341: Oracle rebranding changes for man pages
bpatel
parents: 5506
diff changeset
     1
." Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
."
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
." This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
." under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
." published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
."
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
." This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
." version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
." accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
." You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
." 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
."
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2692
diff changeset
    18
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2692
diff changeset
    19
." or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2692
diff changeset
    20
." questions.
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    21
."
5865
47da38a8c0f0 6955341: Oracle rebranding changes for man pages
bpatel
parents: 5506
diff changeset
    22
.TH javac 1 "02 Jun 2010"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    25
.SH "Name"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
javac \- Java programming language compiler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
.SH "SYNOPSIS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    35
        \fP\f3javac\fP [ options ] [ sourcefiles ] [ classes ] [ @argfiles ]
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    36
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    37
      
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
Arguments may be in any order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
options 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
Command\-line options. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
sourcefiles 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
One or more source files to be compiled (such as MyClass.java). 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
.TP 3
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    56
classes 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    57
One or more classes to be processed for annotations (such as MyPackage.MyClass). 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    58
.TP 3
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
@argfiles 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
One or more files that lists options and source files. The \f2\-J\fP options are not allowed in these files. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
.SH "DESCRIPTION"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    70
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.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
    73
There are two ways to pass source code file names to \f3javac\fP:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
o
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
For a small number of source files, simply list the file names on the command line. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
o
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
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. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
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).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
.SH "OPTIONS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
Standard Options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
.TP 3
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   112
\-Akey[=value] 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   113
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 ".". 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   114
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   115
\-cp path or \-classpath path 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   116
Specify where to find user class files, and (optionally) annotation processors and source files. This classpath 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 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   117
.na
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   118
\f2Setting the Class Path\fP @
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   119
.fi
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   120
http://java.sun.com/javase/6/docs/technotes/tools/index.html#classpath for more details. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   122
If the \f3\-sourcepath\fP option is not specified, the user class path is also searched for source files. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   124
If the \f3\-processorpath\fP option is not specified, the classpath is also searched for annotation processors.  
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   125
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   126
As a special convenience, a class path element containing a basename of \f2*\fP is considered equivalent to specifying a list of all the files in the directory with the extension \f2.jar\fP or \f2.JAR\fP.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
.br
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
.br
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   129
For example, if directory \f2foo\fP contains \f2a.jar\fP and \f2b.JAR\fP, then the class path element \f2foo/*\fP is expanded to \f2A.jar:b.JAR\fP, except that the order of jar files is unspecified. All jar files in the specified directory, even hidden ones, are included in the list. A classpath entry consisting simply of \f2*\fP expands to a list of all the jar files in the current directory. The \f2CLASSPATH\fP environment variable, where defined, will be similarly expanded. \f3Note:\fP \  Depending of the configuration of your command line environment, you may have to quote the wild card character, for example, \f2javac \-cp "*.jar" MyClass.java\fP.  
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
\-Djava.ext.dirs=directories 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
Override the location of installed extensions. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
\-Djava.endorsed.dirs=directories 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
Override the location of endorsed standards path. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
\-d directory 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   138
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. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   140
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. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
\f3Note:\fP \  The directory specified by \f3\-d\fP is not automatically added to your user class path.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
\-deprecation 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   145
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. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
\-encoding encoding 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   148
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. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
\-g 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
Generate all debugging information, including local variables. By default, only line number and source file information is generated. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
\-g:none 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
Do not generate any debugging information. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
\-g:{keyword list} 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
Generate only some kinds of debugging information, specified by a comma separated list of keywords. Valid keywords are: 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
source 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
Source file debugging information 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
lines 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
Line number debugging information 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
vars 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
Local variable debugging information 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
\-help 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
Print a synopsis of standard options. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
.TP 3
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   173
\-implicit:{class,none} 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   174
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. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   175
.TP 3
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
\-nowarn 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
Disable warning messages. This has the same meaning as \f3\-Xlint:none\fP. 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   178
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   179
\-proc: {none,only} 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   180
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. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   181
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   182
\-processor class1[,class2,class3...] 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   183
Names of the annotation processors to run. This bypasses the default discovery process. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   184
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   185
\-processorpath path 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   186
Specify where to find annotation processors; if this option is not used, the classpath will be searched for processors. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   187
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   188
\-s dir 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   189
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. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
\-source release 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
Specifies the version of source code accepted. The following values for \f2release\fP are allowed: 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
1.3 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
The compiler does \f2not\fP support assertions, generics, or other language features introduced after JDK 1.3. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
1.4 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
The compiler accepts code containing assertions, which were introduced in JDK 1.4. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
1.5 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   202
The compiler accepts code containing generics and other language features introduced in JDK 5. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
5 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   205
Synonym for 1.5. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   206
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   207
1.6 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   208
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. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   209
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   210
6 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   211
Synonym for 1.6. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   212
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   213
1.7 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   214
The compiler accepts code with features introduced in JDK 7. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   215
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   216
7 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   217
Synonym for 1.7. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
\-sourcepath sourcepath 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
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. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   223
\f3Note:\fP \  Classes found through the classpath may be subject to automatic recompilation if their sources are also found. See Searching For Types.  
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
\-verbose 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   226
Verbose output. This includes information about each class loaded and each source file compiled. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   227
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   228
\-version 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   229
Print version information. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
\-X 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
Display information about non\-standard options and exit. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
Cross\-Compilation Options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
\-target version 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   249
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). 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
The default for \f3\-target\fP depends on the value of \f3\-source\fP: 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
o
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
If \-source is \f3not specified\fP, the value of \-target is \f31.6\fP 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
o
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   258
If \-source is \f31.2\fP, the value of \-target is \f31.4\fP 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   259
.TP 2
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   260
o
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   261
If \-source is \f31.3\fP, the value of \-target is \f31.4\fP 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
o
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
For \f3all other values\fP of \-source, the value of \-target is the value of \f3\-source\fP. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
\-bootclasspath bootclasspath 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
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. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
\-extdirs directories 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
Cross\-compile against the specified extension directories. \f2Directories\fP is a colon\-separated list of directories. Each JAR archive in the specified directories is searched for class files. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
Non\-Standard Options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
\-Xbootclasspath/p:path 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
Prepend to the bootstrap class path. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
\-Xbootclasspath/a:path 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
Append to the bootstrap class path. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
\-Xbootclasspath/:path 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
Override location of bootstrap class files. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
\-Xlint 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
Enable all recommended warnings. In this release, all available warnings are recommended. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
\-Xlint:none 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
Disable all warnings not mandated by the Java Language Specification. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
.TP 3
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   299
\-Xlint:\-name 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   300
Disable warning \f2name\fP, where \f2name\fP is one of the warning names supported for \f3\-Xlint:\fP\f2name\fP, below. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
\-Xlint:unchecked 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
Give more detail for unchecked conversion warnings that are mandated by the Java Language Specification. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
\-Xlint:path 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
Warn about nonexistent path (classpath, sourcepath, etc) directories. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
\-Xlint:serial 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
Warn about missing \f2serialVersionUID\fP definitions on serializable classes. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
\-Xlint:finally 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
Warn about \f2finally\fP clauses that cannot complete normally. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
\-Xlint:fallthrough 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   315
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: 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
switch (x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
       System.out.println("1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
       //  No  break;  statement here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
case 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
       System.out.println("2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   336
            
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   337
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
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. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
.TP 3
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   343
\-Xmaxerrs number 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
Set the maximum number of errors to print. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
\-Xmaxwarns number 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
Set the maximum number of warnings to print. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
\-Xstdout filename 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
Send compiler messages to the named file. By default, compiler messages go to \f2System.err\fP. 
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   351
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   352
\-Xprefer:{newer,source} 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   353
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. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   354
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   355
\-Xprint 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   356
Print out textual representation of specified types for debugging purposes; perform neither annotation processing nor compilation. The format of the output may change. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   357
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   358
\-XprintProcessorInfo 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   359
Print information about which annotations a processor is asked to process. 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   360
.TP 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   361
\-XprintRounds 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   362
Print information about initial and subsequent annotation processing rounds. 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
The \-J Option
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
.TP 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
\-Joption 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
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. Although it does not begin with \f3\-X\fP, it is not a `standard option' of \f3javac\fP. It is a common convention for \f3\-J\fP to pass options to the underlying VM executing applications written in Java. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
\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.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
.SH "COMMAND LINE ARGUMENT FILES"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
Example \- Single Arg File
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
You could use a single argument file named "\f2argfile\fP" to hold all javac arguments:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   408
  % \fP\f3javac @argfile\fP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   409
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   410
      
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
This argument file could contain the contents of both files shown in the next example.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
Example \- Two Arg Files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
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.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
Create a file named "\f2options\fP" containing:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     \-d classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     \-g
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   434
     \-sourcepath /java/pubs/ws/1.3/src/share/classes
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   435
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   436
      
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
Create a file named "\f2classes\fP" containing:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     MyClass1.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     MyClass2.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     MyClass3.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   454
      
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   455
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   461
You would then run \f3javac\fP with:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  % \fP\f3javac @options @classes\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   468
      
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   469
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
Example \- Arg Files with Paths
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
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):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
  % \fP\f3javac @path1/options @path2/classes\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   484
      
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   485
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   489
.SH "ANNOTATION PROCESSING"
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   490
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   491
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   492
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   493
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   494
\f3javac\fP provides direct support for annotation processing, superseding the need for the separate annotation processing tool, \f3apt\fP.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   495
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   496
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   497
The API for annotation processors is defined in the \f2javax.annotation.processing\fP and \f2javax.lang.model\fP packages and subpackages.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   498
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   499
.SS 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   500
Overview of annotation processing
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   501
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   502
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   503
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
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   504
.br
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   505
\f2\  META\-INF/services/javax.annotation.processing.Processor\fP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   506
.br
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   507
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   508
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   509
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   510
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   511
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   512
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   513
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   514
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   515
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   516
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   517
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   518
.SS 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   519
Implicitly loaded source files
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   520
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   521
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   522
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   523
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   524
.SH "SEARCHING FOR TYPES"
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   525
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   526
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   527
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   528
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   529
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   530
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   531
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   532
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   533
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   534
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   535
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 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   536
.na
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   537
\f2Setting the Class Path\fP @
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   538
.fi
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   539
http://java.sun.com/javase/6/docs/technotes/tools/index.html#classpath).
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   540
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   541
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   542
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   543
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   544
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   545
You can specify different bootstrap or extension classes with the \f3\-bootclasspath\fP and \f3\-extdirs\fP options; see Cross\-Compilation Options below.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   546
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   547
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   548
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   549
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   550
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   551
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   552
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   553
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   554
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   555
.LP
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
.SH "PROGRAMMATIC INTERFACE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   558
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   559
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   560
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   561
\f3javac\fP supports the new Java Compiler API defined by the classes and interfaces in the \f2javax.tools\fP package.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   562
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   563
.SS 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   564
Example
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   565
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   566
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   567
To perform a compilation using arguments as you would give on the command line, you can use the following:
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   568
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   569
.nf
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   570
\f3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   571
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   572
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   573
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   574
int rc = javac.run(null, null, null, args);
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   575
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   576
      
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   577
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   578
\fP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   579
.fi
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   580
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   581
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   582
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   583
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   584
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   585
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   586
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.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   587
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   588
.SS 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   589
Old Interface
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   590
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   591
.RS 3
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   592
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   593
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   594
.LP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   595
\f3Note:\fP \  This API is retained for backwards compatibility only; all new code should use the Java Compiler API, described above.
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   596
.LP
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
The \f2com.sun.tools.javac.Main\fP class provides two static methods to invoke the compiler from a program:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
public static int compile(String[] args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
public static int compile(String[] args, PrintWriter out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   607
      
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   608
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
The \f2out\fP parameter indicates where the compiler's diagnostic output is directed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   620
The return value is equivalent to the exit value from \f3javac\fP.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   625
.RE
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
.SH "EXAMPLES"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
Compiling a Simple Program
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
% \fP\f3ls\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
greetings/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
% \f3ls greetings\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
Hello.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
% \f3cat greetings/Hello.java\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
package greetings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
public class Hello {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        for (int i=0; i < args.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            System.out.println("Hello " + args[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
% \f3javac greetings/Hello.java\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
% \f3ls greetings\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
Hello.class   Hello.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
% \f3java greetings.Hello World Universe Everyone\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
Hello World
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
Hello Universe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
Hello Everyone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   685
        
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   686
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
Compiling Multiple Source Files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
This example compiles all the source files in the package \f2greetings\fP.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
% \fP\f3ls\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
greetings/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
% \f3ls greetings\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
Aloha.java         GutenTag.java      Hello.java         Hi.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
% \f3javac greetings/*.java\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
% \f3ls greetings\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
Aloha.class         GutenTag.class      Hello.class         Hi.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
Aloha.java          GutenTag.java       Hello.java          Hi.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   725
        
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   726
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
Specifying a User Class Path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
Having changed one of the source files in the previous example, we recompile it:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
% \fP\f3pwd\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
/examples
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
% \f3javac greetings/Hi.java\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   753
        
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   754
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
% \fP\f3javac \-classpath /examples /examples/greetings/Hi.java\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   770
        
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   771
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
If we change \f2greetings.Hi\fP again, to use a banner utility, that utility also needs to be accessible through the user class path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   785
% \fP\f3javac \-classpath /examples:/lib/Banners.jar \\ 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   787
            /examples/greetings/Hi.java\fP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   788
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   789
        
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
To execute a class in \f2greetings\fP, we need access both to \f2greetings\fP and to the classes it uses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
% \fP\f3java \-classpath /examples:/lib/Banners.jar greetings.Hi\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   806
        
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   807
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
Separating Source Files and Class Files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
% \fP\f3ls\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
classes/  lib/      src/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
% \f3ls src\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
farewells/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
% \f3ls src/farewells\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
Base.java      GoodBye.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
% \f3ls lib\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
Banners.jar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
% \f3ls classes\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   846
% \f3javac \-sourcepath src \-classpath classes:lib/Banners.jar \\ 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   848
            src/farewells/GoodBye.java \-d classes\fP
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
% \f3ls classes\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
farewells/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
% \f3ls classes/farewells\fP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
Base.class      GoodBye.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   860
        
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   861
.fl
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
\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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
.SS 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
Cross\-Compilation Example
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   877
Here we use \f3javac\fP to compile code that will run on a 1.7 VM.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
.nf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
\f3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   885
% \fP\f3javac \-target 1.7 \-bootclasspath jdk1.7.0/lib/rt.jar \\ 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
.fl
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   887
            \-extdirs "" OldCode.java\fP
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   888
.fl
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   889
        
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
.fl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   896
The \f3\-target 1.7\fP option ensures that the generated class files will be compatible with 1.7 VMs. By default, \f3javac\fP compiles for JDK 6.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
.LP
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   899
The Java Platform JDK's \f3javac\fP would also by default compile against its own bootstrap classes, so we need to tell \f3javac\fP to compile against JDK 1.7 bootstrap classes instead. We do this with \f3\-bootclasspath\fP and \f3\-extdirs\fP. Failing to do this might allow compilation against a Java Platform API that would not be present on a 1.7 VM and would fail at runtime.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
.SH "SEE ALSO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
.RS 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
o
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   909
.na
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   910
\f2The javac Guide\fP @
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   911
.fi
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   912
http://java.sun.com/javase/6/docs/technotes/guides/javac/index.html 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
o
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   915
java(1) \- the Java Application Launcher 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
o
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   918
jdb(1) \- Java Application Debugger 
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   919
.TP 2
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   920
o
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   921
javah(1) \- C Header and Stub File Generator 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
o
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   924
javap(1) \- Class File Disassembler 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
o
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   927
javadoc(1) \- API Documentation Generator 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
o
2692
345bc8d65b19 6837214: Update JDK7 man pages
tbell
parents: 2
diff changeset
   930
jar(1) \- JAR Archive Tool 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
.TP 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
o
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
.na
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
\f2The Java Extensions Framework\fP @
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
.fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
http://java.sun.com/javase/6/docs/technotes/guides/extensions/index.html 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
.RE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
.LP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940