Create a temporary folder
Using Notepad or another text editor,
create a small Java file
HelloWorld.java with the following text:
public class HelloWorld
public static void main(String args)
Save your file as
To make sure your file name is
first choose "Save as file type:"
All files, then type in the file name
Run Command Prompt (found under All Programs/Accessories in the Start menu).
C:\> cd \mywork
This makes C:\mywork the current directory.
This displays the directory contents.
You should see
HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.8.0_51\bin
(use the JDK folder for the version installed on your system).
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
javac.exe, the compiler.
You should see nothing but the next system prompt...
javac has created the
You should see
HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter.
You should see the program output:
If the system cannot find javac,
check the set path command.
If javac runs but you get errors, check your Java text.
If the program compiles but you get an exception, check
the spelling and capitalization in the file name and the class name
java HelloWorld command.
Java is case-sensitive!
It is possible to make the path setting permanent
but you have to be very careful because your system might crash
if you make a mistake.
Proceed with extreme caution!
Go to Control Panel, choose "System,"
click on the "Advanced system settings" link, click on the
"Environment variables" button.
In the lower list, "System variables," click on Path:
and at the end append
(or the path to the appropriate folder where the latest version of JDK is installed).
Do not put spaces before the appended path string.
Click OK on the path edit box and OK on the Ennvironment Variables box.
The new setting will go into effect next time you run Command Prompt.