JAVATM- The Beginnings

The HelloWorld Program

When learning a new programming language, the first task is normally to write a program which simply prints the words “Hello World” to your computer’s display. Once we have written, compiled, and executed the program, and verified that “Hello World” appears on the display, we have successfully run the HelloWorld program.

Section 1 - Creating and Running the HelloWorld Program

In your favorite text editor, or in your programming Integrated Development Environment (IDE), create a file named which contains the following:

Listing 1 -

1        public class HelloWorld

2        {

3                public static void main(String[] args)

4                {

5                        System.out.println("Hello World");

6                }

7        }

To compile and run from the command line, type the following:


java HelloWorld

The Javac command runs the Java compiler which converts Java source file into bytecode file HelloWorld.class. Java source files are text files containing the syntax, or  programming rules, of the Java programming language. All Java source files end with the extension .java .

The Java command runs the HelloWorld.class executable in the Java Virtual Machine (JVM). The following output is now visible on your computer display:

Hello World

Congratulations, you’ve just run your first Java program!

Copyright ©2017 by Ralph Lecessi Incorporated. All rights reserved.

Back to