Name
javac — The Java Compiler
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 can 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. Each source file can contain any number of classes,
although only one can be a public
top-level class.
The name of the source file (minus the .java
extension) must match the name of the public
class
it contains.
In Java 1.2
and later, if a filename specified on the command line begins with
the character @
, that file is taken not as a Java
source file but as a list of compiler options and Java source files.
Thus, if you keep a list of Java source files for a particular
project in a file named project.list, you can
compile all those files at once with the command:
% javac @project.list
To compile a source file, javac must be able to find definitions of all classes used in the source file. It looks for definitions in both source-file and class-file form, automatically compiling any source files that have no corresponding class files or that have been modified since they were most recently compiled.
Common options
The most commonly used compilation options include the following:
-
-classpath
path
Specifies the path javac uses to look up classes referenced in the specified ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.