Java Hello World Program
Last updated: [21-dec-2025]
In this section, we will understand how to create the simple program of Java. We can write a simple hello world Java program easily after installing the JDK.
In Java, every program must have a class, and this class must contain the main() method. The main() method is the starting point of the program. Before we continue, it is important to understand this requirement.
Hello World –Java Program
public class Main{
public static void main(String args[]){
System.out.println("Hello World!");
}
}
Basic Setup for a Hello World Java Program
To run any Java program, the following software and steps are required:
- Install the JDK on your system. If it is not installed, download and install it.
- Set the path of the JDK/bin direstory, so the Java commands can be used from anywhere.
- Create the Java program
- Compile and then run the Java Program.
Creating Hello World Example
Let’s create the Hello world java program.
class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
- Save the program with the name Simple.java
- To compile the program, use the command Javac Simple.java
- To run the program, use the command java Simple
- Output
Hello World
Arguments Used in the First Java Program
class: It is the keyword used to create or declare a class in java.
public: It is an access modifier that represents the visibility. It makes the class or method accessible to everyone.
static: It is the keyword that allows the main method to run without creating an object of the class.
void: The void means that the main() method does not return any value.
main(): The main() is the entry point of a Java program. Program execution starts from this method.