Step 1:
We will create our first Java file, which can be done in any text editor (e.g. Notepad++, Atom, or Sublime Text).
Step 2: Below is the content of Hello World program file, all lines are required:
public class MyClass { public static void main(String[] args) { System.out.println(“Hello World”); } }Step 3:
Save the file as “MyClass.java” because our program name is MyClass. File name must be the same as the main function name.
Step 4:
Open a terminal (cmd, putty, git-bash), navigate to the directory where you saved your file.
Step 5:
Type following command in command line, to compile the code:
In case if there is any syntax or code error, the command prompt will point it.
Step 6:
You will find an executable file “MyClass.class” in the directory where you saved your java program file.
Step 7:
Type following command in command line, to run the file:
It will show you the result of the file. In our case it is printing:
Hello World
Congratulations