13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.3 The Java Compiler117NOTEBy the way, you will notice that we do not cover the installati<strong>on</strong> of the <str<strong>on</strong>g>Development</str<strong>on</strong>g>Kit in this chapter. That is because we are deferring the discussi<strong>on</strong> of installati<strong>on</strong>for the next chapter, where we also introduce the c<strong>on</strong>cept of multiplec<strong>on</strong>current <str<strong>on</strong>g>Development</str<strong>on</strong>g> Kits <strong>on</strong> a single box. See Chapter 6 for details.5.3THE JAVA COMPILERAt the heart of the SDK is javac, the Java compiler. The general form of javacfollows:javac [opti<strong>on</strong>...] [sourcefile...] [@optfile...]The opti<strong>on</strong> list may be zero or more command-line opti<strong>on</strong>s. We’ll detailthose later. The sourcefile list may be the name of zero or more Java sourcefiles. Usually you specify just the “main” class of an applicati<strong>on</strong>. As we will describelater, javac generally will compile all necessary .java files for any classesthat main() class references, directly or indirectly. If you prefix a filename withthe at sign (@), the c<strong>on</strong>tents of the file will be treated as if they had been typed<strong>on</strong> the command line.5.3.1 Compiler Behavior, Defaults, and Envir<strong>on</strong>ment VariablesIn the simplest case—compiling a single class, such as our FetchURL.javaclass—you get no diagnostics <strong>on</strong> success (Example 5.1).Example 5.1 Compiling FetchURL.java$ javac FetchURL.java$There will now be a new file, FetchURL.class, in the directory with theJava source file. Let’s run that again with a command-line opti<strong>on</strong> we will detaillater (Example 5.2).Boy, our single, simple, <strong>on</strong>e-class applicati<strong>on</strong> sure uses a lot of classes! Itdoes. Where did they come from? They come from the classes referenced by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!