'\" t .\" @(#)javac.1 1.5 98/04/20 SMI; .\" Copyright (c) 1996 Sun Microsystems, Inc. .\" All Rights Reserved. '\"macro stdmacro .TH javac 1 "8 June 1997" .SH NAME javac \- Java compiler .\" .\" This document was created by saving an HTML file as text .\" from the JavaSoft web site: .\" .\" http://www.javasoft.com:80/products/jdk/1.1/docs/tooldocs/solaris/index.html .\" .\" and adding appropriate troff macros. Because the JavaSoft web site .\" man pages can change without notice, it may be helpful to diff .\" files to identify changes other than new functionality. .\" .SH SYNOPSIS .B javac [ .BI \-classpath " path" ] [ .BI \-d " directory" ] [ .B \-depend ] .if n .ti +5n [ .B \-deprecation ] .if t .ti +5n [ .BI -encoding " encoding_name" ] .if n .ti +5n [ .B \-g ] [ .BI \-J javaoption ] [ .B \-nowarn ] [ .B \-O ] .ti +5n [ .B \-verbose ] \f2filename\f3.java\fP ... .LP .B javac_g [ .BI \-classpath " path" ] [ .BI \-d " directory" ] [ .B \-depend ] .if n .ti +5n [ .B \-deprecation ] .if t .ti +5n [ .BI -encoding " encoding_name" ] .if n .ti +5n [ .B \-g ] [ .BI \-J javaoption ] [ .B \-nowarn ] [ .B \-O ] .ti +5n [ .B \-verbose ] \f2filename\f3.java\fP ... .SH DESCRIPTION The .B javac command compiles Java\(tm source code into Java bytecodes that can then be used by the .BR java (1) interpreter to interpret the Java bytecodes. .LP Java source code must be contained in files which filenames thatend with the .B .java extension. The file name must be constructed from the class name, as \f2classname.\fP\f3java\fP, if the class is public or is referenced from another source file. .LP For every class defined in each source file compiled by .BR javac , the compiler stores the resulting bytecodes in a class file with a name of the form \f2classname.\fP\f3class\fP. Unless you specify the .B \-d option, the compiler places each class file in the same directory as the corresponding source file. .LP When the compiler must refer to your own classes, you need to specify their location. Use the .B \-classpath option or .SB CLASSPATH environment variable to do this. The class path is a sequence of directories (or zip files) that .B javac searches for classes not already defined in any of the files specified directly as command arguments. The compiler looks in the class path for both a source file and a class file, recompiling the source (and regenerating the class file) if it is newer. .LP Set the property .B javac.pipe.output to true to send output messages to .BR System.out . Set .B javac.pipe.output to \s-1\f3FALSE\s0\fP, that is, do not set it, to send output messages to .BR System.err . .LP .B javac_g is a non-optimized version of .B javac suitable for use with debuggers like .BR jdb (1) for debugging .B javac itself. Using .B javac_g is .I not equivalent to using the command \f3javac \-g\f1. .SH OPTIONS .TP 15 .BI \-classpath " path" Specifies the path .B javac uses to look up classes needed to run .B javac or being records by other classes you are compiling. . Overrides the default or the .SB CLASSPATH environment variable if it is set. Directories are separated by colons. It is often useful for the directory containing the source files to be on the class path. You should always include the system classes at the end of the path. For example: .sp 1n .RS 20 .B example% javac -classpath .:/home/avh/classes:/usr/local/java/classes ... .sp 1n .RE .TP 15 .BI \-d " directory" Specifies the root directory of the class file hierarchy. In other words, this is essentially a destination directory for your compiled classes. For example, doing: .sp 1n .RS 20 .B example% javac \-d /home/avh/classes MyProgram.java .sp 1n .RE .RS 15 causes the compiled class files for the classes in the .B MyProgram.java source file to be saved in the directory .BR /home/avh/classes/demos/awt . If your classes are defined in the package .BR demos/awt , the class files would be placed in the directory .BR /home/avh/classes/demos/awt . .LP Please note that the .BR \-d " and " \-classpath options have independent effects. The compiler reads only from the class path, and writes only to the destination directory. It is often useful for the destination directory to be on the class path. If the .B -d option is not specified, the source files should be stored in a directory hierarchy that reflects the package structure, so that the resulting class files can be easily located. .RE .TP 15 .B \-depend This option makes the compiler consider recompiling class files that are referenced from other class files. Normally, it only recompiles missing or out-of-date class files that are referred to from source code. .TP 15 .B \-deprecation Generate a warning for every use or override of a deprecated member or class. A member or class is deprecated if its documentation comment contains the \f3@deprecated\f2 tag. The compiler will emit a morning at the end of compilation whether or not .B \-deprecation is used; this option causes the location of each individual use or override to be noted. .LP .RS 15 Deprecated members or classes are deliberately not mentioned if the source file containing the deprecation is being recompiled. This can happen because the file is on the command line or because .B \-depend is used and the source file was out of date. .RE .TP 15 .BI -encoding " encoding_name" Specify the source file encoding name, such as EUCJIS/SJIS. If this option is not specified, then the platform default converter is used. .TP 15 .B \-g Enables generation of debugging tables. Debugging tables contain information about line numbers and local variables - information used by Java debugging tools. By default, only line numbers are generated, unless optimization (\f3\-O\fP) is turned on. .TP 15 .BI \-J javaoption Passes through the string .I javaoption as a single argument to the .BR java (1) interpreter that runs the compiler. The argument should not contain spaces. Multiple argument words must all begin with the prefix .BR \-J , which is stripped. This is useful for adjusting the compiler's execution environment or memory usage. .TP 15 .B \-nowarn Turns off warnings. If used, the compiler does not print out any warnings. .TP 15 .B \-O Directs the compiler to try to generate faster code by inlining static, final and private methods. This option may slow down compilation, make larger class files, and/or make it difficult to debug. .B \-O implicitly turns on .B \-depend and turns off .BR -g . .RS 15 .LP This option informs the compiler that all generated class files are guaranteed to be delivered and upgraded as a unit, enabling optimizations that may otherwise break binary compatibility. Use this option with discretion. .LP .RE .RS 15 The Java Language Specification section 13.4.21 describes situations in which it is legal to use a java compiler to inline methods. The compiler will only optimize code for source which is available during the compilation, so the only \f3.java\f2 files discoverable by the compiler should be for classes intended to be delivered or upgraded as a unit. In particular, ensure that no sources for other classes are accessible on \s-1\f3CLASSPATH\s0\f2, keeping in mind that the present working directory, `.', is appended to \s-1\f3CLASSPATH\s0\f2. .RE .RS 15 .LP To ensure that a product is able to run on 1.1 as well as future binary-compatible java virtual machines, one must ensure that any sources for JDK 1.1 classes are never available along \s-1\f3CLASSPATH\s0\f2 while using .BR \-O . .RE .TP 15 .B \-verbose Causes the compiler and linker to print out messages about what source files are being compiled and what class files are being loaded. .SH EXAMPLE .SS Compiling One or More Classes In this example, the source files are located at .BR /home/ws/src/java/awt/*.java . .RS 5 .nf \f3 % cd /home/ws/src/java/awt/ % javac Button.java Canvas.java \f2 .fi .RE Compiles the two classes. .SH ENVIRONMENT VARIABLES .TP 15 .SB CLASSPATH Used to provide the system with a path to user-defined classes. Directories are separated by colons, for example, .RS 20 .sp 1n .B .:/home/avh/classes:/usr/local/java/classes .RE .SH ATTRIBUTES See .BR attributes (5) for a description of the following attributes: .sp .TS box; cbp-1 | cbp-1 l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE = Availability SUNWjvdev .TE .SH SEE ALSO .BR java (1), .BR javadoc (1), .BR javah (1), .BR javap (1), .BR jdb (1), .BR attributes (5)