8 Steps to run the Java program using a command prompt.
- class HelloWorld {
- public static void main(String args[]) {
- System.out.println("Hello Java");
- }
- }
Step 2: Save it as HelloWorld.java (For example: It is saved in C:\Users\comp\Java Practiced program).
Step 3: Set the environment variable.
Right Click on MyComputer -> Properties -> Advanced System settings -> Inside Advanced tab
Click Environment variables -> Inside System Variables click New -> Give variable name (For example var) -> Give variable value. It is path in your system where java compiler is available (For example variable value :C:\Program Files\Java\jdk1.6.0_23\bin ). Inside bin javac is Java compiler.
Click Ok.
Step 4: Go to the command prompt by using start->Run->cmd OR start-> type cmd in the search program and file.
Press Enter.
Step 5: Use the following command to go to the folder where the previous Java program is stored.
cd C:\Users\comp\Java Practiced program
Press enter
Step 6: Set the path of Compiler. It is a path in your system where java compiler is available
For example, set path=C:\Program Files\Java\jdk1.6.0_23\bin;
Press enter
Step 7: Write the following command for the compilation of the program.
javac HelloWorld.java
Press Enter
Step 8: To run the program using the following command
java HelloWorld
Now output is shown: Hello Java
If any query mail Please mail me on [email protected] or comment it...


Dominik CebulaPosted Dec 31, 2021, 6:17 AM EST
Hello, recently I have created "Java Plugin for Notepad++" that allows you to compile and run java in Notepad++.You can find more information here https://github.com/dominikcebula/npp-java-plugin
Malvika gargPosted May 19, 2019, 11:18 PM EDT
I can also copy the environment varibles but 'javac' is not recognized as an internal or external command,operable program or batch file. this error is show
Malvika gargPosted May 19, 2019, 11:17 PM EDT
Plz tell me.....
Malvika gargPosted May 19, 2019, 11:16 PM EDT
How to solve the problem of javac
Adarsh SinghPosted May 11, 2019, 4:04 AM EDT
This is showing this statement 'javac' is not recognized as an internal or external command,operable program or batch file. then how i can run programme
pankaj dixitPosted Jun 23, 2014, 12:47 AM EDT
thanks vaishali it is valuable for beginers..........:)
Abhijit PatilPosted Jun 20, 2014, 11:43 PM EDT
nice vaishali ,keep sharing same artical