Java – Hello World


This is simple Hello World! java program. In this tutorial you will get a simple java program to print “Hello World!” on console.

Let’s create a file HelloWorld.java and add following code.

class HelloWorld{  
    public static void main(String args[]){  
         System.out.println("Hello World");  
    }  
}  

Compile java program using javac command.

$ javac HelloWorld.java

After compilation, it will create a HelloWorld.class file. Now use following command to run program.

$ java HelloWorld

[Output]
Hello World