Java Reference
In-Depth Information
The Java interpreter executes all assert statements in the application's class and all other
class files that it uses, with the exception of classes from the Java class library.
To remove that exception and make use of all assertions, run a class with the -esa
option.
If you don't specify one of the options that turns on the assertions feature, all assert
statements will be ignored by the interpreter.
The javac Compiler
The Java compiler, javac , converts Java source code into one or more class files of byte-
code that can be run by a Java interpreter.
B
Java source code is stored in a file with the .java file extension. This file can be created
with any text editor or word processor that can save a document without any special for-
matting codes. The terminology varies depending on the text-editing software being
used, but these files are often called plain text, ASCII text, DOS text, or something
similar.
A Java source code file can contain more than one class, but only one of the classes can
be declared to be public. A class can contain no public classes at all if desired, although
this isn't possible with applets because of the rules of inheritance.
If a source code file contains a class that has been declared to be public, the name of the
file must match the name of that class. For example, the source code for a public class
called BuyItem must be stored in a file called BuyItem.java .
To compile a file, the javac tool is run with the name of the source code file as an argu-
ment, as in the following:
javac BuyItem.java
You can compile more than one source file by including each separate filename as a
command-line argument, such as this command:
javac BuyItem.java SellItem.java
You also can use wildcard characters such as * and ? . Use the following command to
compile all .java files in a folder:
javac *.java
When you compile one or more Java source code files, a separate .class file will be cre-
ated for each Java class that compiles successfully.
 
Search WWH ::




Custom Search