Start of Tutorial > Start of Trail | Search |
By following the steps on this page, you can create and use a standalone Java application.
Using a text editor, create a file namedHelloWorldApp.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 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 program using the Java interpreter.You should see "Hello World!" displayed. If you have any trouble running the "Hello World" application, see Interpreter Problems.
Now you can:
- Continue on in this lesson to learn more about the anatomy of applications, how the "Hello World" application works, and how the Java language implements object-oriented concepts.
- Go to the next lesson, The "Hello World" Applet, which steps you through writing and running an applet, as well as introducing you to a few more Java features.
- Learn more about the Java language by going to the Learning the Java Language trail.
Start of Tutorial > Start of Trail | Search |