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, 11:17 AM
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 20, 2019, 3:18 AM
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 20, 2019, 3:17 AM
Plz tell me.....
Malvika gargPosted May 20, 2019, 3:16 AM
How to solve the problem of javac
Adarsh SinghPosted May 11, 2019, 8:04 AM
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, 4:47 AM
thanks vaishali it is valuable for beginers..........:)
Abhijit PatilPosted Jun 21, 2014, 3:43 AM
nice vaishali ,keep sharing same artical