next up previous
Next: 1.8.3 When to Use Up: 1.8.2 Complete Java Programs Previous: 1.8.2 Complete Java Programs

1.8.2.1 A Complete Java Program

The following simple program

class Motto {
  public static void main(String[] args) {
    System.out.println("Java rules!");  
  }
}
prints the String output
Java rules!
and stops when the Java program with root-class Motto is executed. Before any Java program can be executed, it must be compiled into a form suitable for machine execution called a class file Motto.class. The name of the class file generated for a class C is simply C.class.

In DrJava, the Compile button applies the compiler to each open Java files and write out the resulting class files to the file system--assuming that the files did not contain any syntax errors. Each class file is stored in the same direcoty as the corresponding source (.java) class.


Finger Exercise: Using DrJava, define the Motto class given above and execute it as program.



Corky Cartwright 2003-07-07