Java Reference
In-Depth Information
7. Compile the Book class.
8. Run the Book program, using two command-line arguments:
java Book “Green Eggs and Ham” “Dr. Seuss”
If you run the Book program and forget to enter two command-line
arguments, you will see an “exception in thread main” java.lang.Array
IndexOutOfBounds-Exception. This would happen, for example, if you
tried to access args[1], and there was no string at that position in the args
array.
Summary
Java is an object-oriented programming language that is interpreted by
a Java Virtual Machine (JVM), allowing it to be platform independent.
■■
There are three editions of Java: J2SE, the Java 2 Platform, Standard Edi-
tion, which is covered in this topic; J2ME, the Java 2 Platform, Micro
Edition, which is for electronic devices with limited resources; and
J2EE, the Java 2 Platform, Enterprise Edition, which is a collection of
Java technologies that includes servlets, JavaServer Pages, and Enter-
prise JavaBeans.
■■
Writing Java code involves writing classes. A class is saved in a .java
file, and only one public class can appear in a .java file. The name of the
.java file must be the name of the public class declared in the file.
■■
Compiled Java code is referred to as bytecode. Bytecode appears in a
.class file.
■■
To compile a Java program, you use the javac tool that comes with the
Standard Developer Kit (SDK), which is freely downloadable from
Sun's Web site.
■■
To run a Java program, you use the java tool that comes with the SDK.
The java tool is a JVM.
■■
The JVM invokes the main() method. The signature of main() is public
static void main(String [] args).
■■
Search WWH ::




Custom Search