1) Create a temporary folder and name it whatever you want.
![]() |
| Created a temporary folder named "Java Programs" on "Documents" |
2) Open Windows Notepad or any other text editors.
3) Copy and paste simple code that is written below.
public class MyFirstProgram {
public static void main(String args[]) {
System.out.print("Hello World!");
}
}
4) Save the file as "MyFirstProgram.java" to temporary folder.
![]() |
| Saved a file (MyFirstProgram.java) to "Java Programs" folder |
5) Open command prompt. (Win + R > Type "cmd")
6) Locate where the file is. (In my case, the file is under "Documents" > "Java Programs" folder)
7) Once located, type "javac MyFirstProgram.java" to compile the code. This command will create a class file. If no error occurs, it will leave a new line.
8) After that, type "java MyFirstProgram" to run the code. If no error occurs, it will print out the output which is "Hello World!". Otherwise, it will not print and give you error messages.
7) Once located, type "javac MyFirstProgram.java" to compile the code. This command will create a class file. If no error occurs, it will leave a new line.
![]() |
| NOTE : Locate first where the file is. (Type "cd documents\ java programs") |
![]() |
| Class file ; Compiled Java bytecode |
8) After that, type "java MyFirstProgram" to run the code. If no error occurs, it will print out the output which is "Hello World!". Otherwise, it will not print and give you error messages.
![]() |
| Printed out the result "Hello World!" |












