Create, Compile and Run the Hello World Program in Java
Java programs can be written in a very easy manner, follow the below two steps to create, compile and run the program.
1. Open a text editor, write the following "Hello World" program and save the file with .java extension i.e. HelloWorld.java
Note: The file name should be the same as the class name with extension .java - for example, if the class name is HelloWorld then the file name should be HelloWorld.java
Hello World Program - HelloWorld.java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
2. Compile the java file (i.e. java program) using the command javac HelloWorld.java and execute the compiled byte code using the command java HelloWorld