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
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
The default VM is client.
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 java.com/en/download/
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
- Open notepad and type following code in it and save it as test.java in
public static void main(String args)
System.out.print("Hello! Isrg Rajan");
- Once you have saved the file in the
- Open command prompt and type
cd C:/Codesand pres enter (cd stands for change directory)
- After changing directory Type
javaccommand is used to generate the java class file. In this case it will generate a class file named
- Once the class file is generated use
java testto 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-
- Open command prompt and located directory
C:\Program Files\Java\jdkx.x.x_xx\bin\using Windows explorer
- Copy the path and in the command promote run following command
set path=[your JDK path]And press enter
That’s all folks!