How to compile & run a Java program using Command Prompt?n

While many programming environments allow us to compile and run a program within the environment, we can also compile and run java programs using Command Prompt.

After successful installation of JDK in our system and set the path, we can able to compile and execute Java programs using the command prompt.

  • Step 1  -   Need to create a java program either in Notepad or other IDE.
  • Step 2  -   Need to save this java file in a folder with "" and it can be saved in a folder.
  • Step 3  -   Need to compile this java file from the command prompt using JAVAC command.
  • Step 4  -  "" file is successfully compiled with a generation of ".class" file.
  • Step 5  -   Need to execute this java file using JAVA command without ".java" extension.
  • Step 6  -   Able to see "Welcome to TutorialsPoint" output in the console.


class Demo{
   public static void main(String args[]){
      System.out.println("Welcome to Tutorials Point");


Welcome to TutorialsPoint