Using Java in Windows Command Prompt
It seems that the Java Runtime Environment installer doesn’t automatically add the binary path of java and javac to the system environment variables, so the ‘java’ and ‘javac’ commands can’t be used without a path. For example, when you type “javac test.java” while in your test project directory, you might get the following message:
‘javac’ is not recognized as an internal or external command, operable program or batch file.
The solution to this problem is pretty simple and should take less than two minutes to solve, so let’s solve it…
Start by locating a directory named ‘bin’ the installation directory of Java Runtime Environment on your computer. On my computer, it’s “C:\Program Files\Java\jdk1.6.0_05\bin”. Once you find it, copy the directory’s path.
Now the solution - right-click “My Computer” and click properties.
In System Properties, go to the “Advanced Tab” and then click “Environment Variables”.
Locate the “path” item in the “System Variables” list and click “Edit”.
Append the path of your bin directory with a leading semicolon (;) and enclose it with quotes. For example, I would append:
;”C:\Program Files\Java\jdk1.6.0_05\bin”
Click “Ok”, “Ok”, and finally “Ok”.
Now go to the Command Prompt (Winkey + R > “cmd” > Enter) and type “javac -version”, you should get something like:
C:\Documents and Settings\Tim>javac -version
javac 1.6.0_05
Hooray.
Tags: Java, Programming, solutions, troubleshooting