next up previous
Next: Loose Ends Up: Complete Java Programs Previous: Complete Java Programs

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 1.11.2.1: Using DrJava, define the Motto class given above and execute it as program.



Corky Cartwright 2004-02-05