javac - The Java Compiler
javac compiles Java programs.
SYNOPSIS
javac [ options ] filename.java...
javac_g [ options ] filename.java...
DESCRIPTION
The javac command compiles Java source code contained in the files
specified by
filename.java... into class files containing Java bytecodes. Filenames
must end in the .java extension.
Java classes are interpreted by the java command.
Every class defined in the files passed to javac has its resulting
bytecodes
stored in a file named classname.class. The .class file is stored in
the same directory as the corresponding .java file, unless the -d
option is used. If a class in one of the
files passed to javac references a class not in any of the files passed
to javac then javac searches for the referenced class using the
class path.
When you define your own classes you need to specify their location.
Use CLASSPATH to do this.
CLASSPATH consists of a semicolon separated list of directories that specifies the
path.
For example:
.;C:\users\lindholm\classes
Note that the system always appends the location of the system classes
onto the end of the class path unless you use the -classpath option to
specify a path.
javac_g is a non-optimized version of javac suitable for use with
debuggers like dbx or gdb.
- -classpath path
- Specifies the path javac uses to look up classes. Overrides the default
or the CLASSPATH environment variable if it is set. Directories are separated by
semicolons. Thus the general format for path is:
.;<your_path>
For example:
.;C:\users\lindholm\classes;D:\java\classes
- -d directory
- Specifies the root directory of the class hierarchy. Thus doing:
javac -d <my_dir>\editor\gui\TextWindow.java
causes the class file for the class called editor.gui.Textwindow to be
saved as:
<my_dir>\editor\gui\TextWindow.class
- -g
- Enables generation of debugging tables. Debugging tables contain
information about line numbers and local variables - information used by
debugging tools. By default, this option is on. To turn debugging table
generation off, use the -ng option.
- -ng
- Disables generation of debugging tables. This makes the Java bytecode
files smaller, but makes it impossible for debugging tools to access local
variables or print out line numbers.
- -nowarn
- Turns off warnings. If used the compiler does not print out any warnings.
- -O
- Optimizes compiled code by inlining static, final and private methods.
Note that your classes may get larger in size.
- -verbose
- Causes the compiler and linker to print out messages about what source
files are being compiled and what class files are being loaded.
ENVIRONMENT VARIABLES
- CLASSPATH
- Used to provide the system a path to user-defined classes. Directories are
separated by semicolons, for example,
.;C:\users\lindholm\classes;D:\java\classes
SEE ALSO
java, javah,
javaprof, javap,
javadoc
The Java Language
Specification