Appendix G. Tool Summary

In this summary, we use a monospaced font for actual commands such as javac. An italic font denotes descriptions of tool command components such as options. Items enclosed in brackets [...] are optional. Items separated by vertical bars | are alternatives. Do not include the brackets or vertical bars when typing the commands.

The Java Compiler

javac [options] sourceFile1|@fileList1 sourceFile2|@fileList2 ...

A file list is a text file that contains one file name per line. For example,

File Greeting.list

1  Greeting.java
2  GreetingTest.java

Then you can compile all files with the command

javac @Greeting.list

The Java compiler options are summarized in Table 1.

Table G.1. Common Compiler Options

Option

Description

-classpath locations

or

-cp locations

The compiler is to look for classes on this path, overriding the CLASSPATH environment variable. If neither is specified, the current directory is used.

Each location is a directory, JAR file, or ZIP file. Locations are separated by a platform-dependent separator (: on Unix, ; on Windows).

-sourcepath locations

The compiler is to look for source files on this path. If not specified, source files are searched in the class path.

-d directory

The compiler places files into the specified directory.

-g

Generate debugging information.

-verbose

Include information about all classes that are being compiled (useful for troubleshooting).

-deprecation

Give detailed information about the usage of deprecated messages.

-Xlint: errorType

Carry out additional ...

Get Big Java, 4th 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.