First Java Program ( Hello World Program )

In this tutorial you will learn about the First Java Program ( Hello World Program ) and its application with practical example.

Writing Your First Java Program ( Java Hello World Program )

We break the process of programming in Java into three steps:

  • Create the program by typing it into a text editor program and saving it to a file named, say, HelloWorld.java.
  • Compile it by typing “javac HelloWorld.java” in the command prompt.
  • Run (or execute) it by typing “java HelloWorld” in the command prompt.

The first step creates the program; the second translates it into an intermediate binary code (called bytecode) and puts the result in a file named HelloWorld.class; the third step actually runs or executes the program.

Creating a Java program.

Copy the following code into your text editor and save it into a file named HelloWorld.java.

 

Compiling a Java program.

To compile HelloWorld.java type the text below in the command prompt. (Here % symbol is used to denote the command prompt, but it may appear different depending on your system.)

Executing a Java program.

After compiling your java program, you can run it. To run the HelloWorld program, type the following in the command prompt:

If all goes well, you should see the following response

In this tutorial we have learn about the First Java Program ( Hello World Program ) and its application with practical example. I hope you will like this tutorial.