Isrg KB
The Best Way to Gain Knowledge

Running Your First Java Core Program With Notepad and CMD

How to Run Java Codes using notepad and CMD in Windows 7, 8 or 10?

Java programming is widely used by almost maximum amount of developer. It is considered to be one of safest programming languages to code and develop apps and software for personal and commercial purposes. Learning Java programming has a wide range of opportunities in Web Development, Software development and research. Choosing Java as your main programming field has numerous scopes in Information Technology.

In today’s date Java is being used to develop apps for portable devices like mobile, hybrid tabs, etc. Java is also used in various gadgets and vehicles like car, video games etc.

In this article we have included the steps towards running your first Java Program using Notepad and Command Prompt (CMD).

Things you will need

  • Notepad (we recommend Notepad++)
  • Basic knowledge of Command Prompt (CMD)
  • Java Development Kit (JDK)

First check if you have already installed Java using CMD. In order to check if Java is installed or not follow following steps –

  • Press Window Key+R
  • And in run type “CMD” (without quotes)
  • Once cmd promote opens, type “Java” (without quotes) and press enter
  • If it gives following output then it means you have already installed Java on your PC

If it gives different output something like command not recognized, it means you don’t have Java on your PC. Well, you can download and install the latest version of Java from

Once you have successfully installed Java on your PC, follow following steps to run your first Java Programme-

  • Go to C:/ drive and create a new folder and name it Codes
  • Open notepad and type following code in it and save it as in C:/Codes/

  • Once you have saved the file in the Codes folder as
  • Open command prompt and type cd C:/Codes and pres enter (cd stands for change directory)
  • After changing directory Type javac
  • javac command is used to generate the java class file. In this case it will generate a class file named test.class
  • Once the class file is generated use java test to run your programme
  • In case it results error something like command not reorganized, it means that Java path needs to be set
  • See below on How to Set path in Java-

How to Set Path in Java using CMD?

In order to set path in Java follow following stetps-

  1. Open command prompt and located directory C:\Program Files\Java\jdkx.x.x_xx\bin\ using Windows explorer
  2. Copy the path and in the command promote run following command
  3. set path=[your JDK path] And press enter

That’s all folks!