Java Reference
In-Depth Information
NOTE
By the way, you will notice that we do not cover the installation of the Develop-
ment Kit in this chapter. That is because we are deferring the discussion of in-
stallation for the next chapter, where we also introduce the concept of multiple
concurrent Development Kits on a single box. See Chapter 6 for details.
5.3
T HE J AVA C OMPILER
At the heart of the SDK is javac , the Java compiler. The general form of javac
follows:
javac [ option ...] [ sourcefile ...] [ @optfile ...]
The option list may be zero or more command-line options. We'll detail
those later. The sourcefile list may be the name of zero or more Java source
files. Usually you specify just the “main” class of an application. As we will de-
scribe later, javac generally will compile all necessary .java files for any classes
that main() class references, directly or indirectly. If you prefix a filename with
the at sign ( @ ), the contents of the file will be treated as if they had been typed
on the command line.
5.3.1
In the simplest case—compiling a single class, such as our FetchURL.java
class—you get no diagnostics on success (Example 5.1).
Compiler Behavior, Defaults, and Environment Variables
Example 5.1 Compiling FetchURL.java
$ javac FetchURL.java
$
There will now be a new file, FetchURL.class , in the directory with the
Java source file. Let's run that again with a command-line option we will detail
later (Example 5.2).
Boy, our single, simple, one-class application sure uses a lot of classes! It
does. Where did they come from? They come from the classes referenced by
Search WWH ::




Custom Search