Compile Your First Java program using notepad for beginners

Rutu Shah
2 min readJan 1, 2021

Java is widely used high level programming language that was originally developed by Sun Microsystems.

Moreover, there are myriads of IDES available to code java source code, among them few are listed below.

  1. Eclipse
  2. Intellij
  3. NetBeans
  4. Blue J
  5. Dr java and so on.

However, in this blog I will show you how to compile your first java program through notepad.

Following are the steps to compile java code through Notepad

Step1 : Open Notepad from search -> enter Notepad and open Notepad.

Step2 : Once you open notepad, enter following code in Notepad.

public class Demo{

public static void main(String args[]){

System.out.println(“Hello, coders !!!”);
}
}

Step3 : Now, save your file as Demo.java file into your system and make sure that you while saving your file you change “Save as type to All files” instead of “Text Documents (*.txt).

Step4: To compile your java code, please open command prompt and enter the below mention code:

Command Explanation :

Here, I have saved my file as Demo.java so I am adding Demo.java, you can type your file name through which you have saved your java file.

javac is a used to compile your code for java

Demo.java is java file name

Step5: If you look in your working folder, you can see that a file named Demo.class has been created.

Step6: After compiling our source code we will execute our code by entering the command java followed by the class name, as expected output Hello, coders !!! is displayed in cmd.

Note : Java follows Write Once Run Anywhere principle , i.e you can run the java programs as many times you want on a java supported platform after it is compiled.

Also Java is case sensitive programming language, i.e Hello and hello both are different.

In addition to this you can copy and paste the same code in IDE like Eclipse or intellij IDEA as compiling and execution is done easily just with the click of a button. More using IDE is more efficient, but since you are learning Java, I recommend you to practice some programs on notepad only.

--

--