Java Hello World Program

Simple Hello World Example in Java Programming

In this chapter, we will learn How to write and run the hello world – the simplest java program. Before we can run our first Java program or any other java program, we need some requirements on our machine. And we need some steps for running our program.

System setup & Steps before running Java

As we discussed in the Java introduction that Java is a compiled language. So before running Java, we have to set up the Java compiler on our machine. The default compiler of the Java program is the official JDK (Java Development Kit).

Then you need a text editor to write our Java program. Finally, we will compile and run our program.

To be precise;

Install the JDK, if you don’t already have installed. JDK is available here.

Create your Hello World program and name it Hello.java using a text editor.

Compile your program using javac command.

Finally, run the compiled program.

HINTS: The full Java Installation guide available here.

Java ProgramFlow

When you create a java file with the .java file extension, it is the main programable java file. When you compile it, the java file is converted into bytecode. The bytecode stored in the .class file. Finally, the bytecode trans compiled into the machine-readable executable code. See the diagram below;

Writing Hello World Program

After successfully installed the JDK create a java file called Hello.java and write the following code in the file.