The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search

Trail: Getting Started

Lesson: The "Hello World" Application

By following the steps on this page, you can create and use a standalone Java application.

Create a Java Source File

Using a text editor, create a file named HelloWorldApp.java with the following Java code:
/** 
 * The HelloWorldApp class implements an application that
 * simply displays "Hello World!" to the standard output.
 */
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); //Display the string.
    }
}

Compile the Source File

Compile the source file using the Java compiler.

If the compilation succeeds, the compiler creates a file named HelloWorldApp.class in the same directory (folder) as the Java source file (HelloWorldApp.java). This class file contains Java bytecodes, which are platform-independent codes interpreted by the Java runtime system.

If the compilation fails, make sure you typed in and named the program exactly as shown above, using the capitalization shown. If you can't find the problem, Compiler Problems might be able to help you.

Run the Application

Run the program using the Java interpreter.

You should see "Hello World!" displayed. If you have any trouble running the "Hello World" application, see Interpreter Problems.

What Next?

Now you can:

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search