Hello World Program in Java
How to write, compile and run hello world program in java?
Step 1- Open Notepad
Step 2- Copy below code and paste it.
Step 3- Save file as class name. Ex: HelloWorld.java
Step 4- Open folder where source file (HelloWorld.java) exist
Step 5- Open command prompt and compile HelloWorld.java file.Ex: c:\>javac HelloWorld.java
Step 6- now run HelloWorld.class file see in folder if compiled successfully. Ex: c:\>java HelloWorld
Output will be : Hello World!
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Output:
Hello World!
How to write, compile and run hello world program in java?
Open Notepad, Copy below code and paste it, Save file as class name. Ex: HelloWorld.java, Open folder where source file (HelloWorld.java) exist, Open command prompt and compile HelloWorld.java file.Ex: javac HelloWorld.java, now run HelloWorld.class file see in folder if compiled successfully. Ex: java HelloWorld