Previous | Next | Trail Map | Getting Started | The "Hello World" Application


The Anatomy of a Java Application

Now that you've seen a Java application (and perhaps even compiled and run it), you might be wondering how it works and how similar it is to other Java applications. Remember that a Java application is a standalone Java program-- a program written in the Java language that runs independently of any browser.

Note: If you couldn't care less about Java applications and just want to get to applets, skip ahead to The "Hello World" Applet.(in the Getting Started trail)

Once Again, the Code

Here again is the code for the "Hello World" application.
class HelloWorldApp {
    public static void main (String args[]) {
        System.out.println("Hello World!");
    }
}

Defining a Class

In the Java language, all methods (functions) and variables exist within a class or an object (an instance of a class). The Java language does not support global functions or stray variables. Thus, the skeleton of any Java program is a class definition.

The main() Method

The brain of every Java application is its main() method. When you run an application with the Java interpreter, you specify the name of the class that you want to run. The interpreter invokes the main() method defined within that class. The main() method controls the flow of the program, allocates whatever resources are needed, and runs any other methods that provide the functionality for the application.

Using Classes and Objects

The other components of a Java application are the supporting objects, classes, methods, and Java language statements that you write to implement the application.


Previous | Next | Trail Map | Getting Started | The "Hello World" Application