javac

Name

javac---The Java Compiler

Availability

JDK 1.0 and later.

Synopsis

javac [ options ] files 

Description

javac is the Java compiler--it compiles Java source code (in .java files) into Java byte-codes (in .class files). The Java compiler is itself written in Java.

javac may be passed any number of Java source files, whose names must all end with the .java extension. javac produces a separate .class class file for each class defined in the source files, regardless of how many source files there are. In other words, there need not be a one-to-one mapping between Java source files and Java class files. Note also that the compiler requires that there be only a single public class defined in any one source file, and that the name of the file (minus the .java extension) be the same as the name of the class (minus its package name, of course).

javac places the class files it generates in the same directory as the corresponding source file. You can override this behavior with the -d option.

When a source file references a class that is not defined in another source file on the command line, javac searches for the definition of that class using the class path. The default class path contains only the current directory and the system classes. You may specify additional classes and packages to be searched with the -classpath option or the CLASSPATH environment variable.

If javac compiles a source file that relies on a class that is out of date (i.e., if the source file for that class is newer than the class file), it automatically recompiles that file.

Options

Environment

See Also

java, jdb