I'm trying to use javac
with the windows command prompt, but it's not working.
After adding the directory "C:\Program Files\Java\jdk1.6.0_16\bin\"
to the end of the PATH
environment variable, the java
command works fine, but using javac
gives me the following error:
'javac' is not recognized as an internal or external command, operable program or batch file.
I just had to do this to get this to work on windows 7 64.
Open up a command prompt (cmd.exe) and type:
Make sure you reopen all running command prompt Windows to get the environment variable updated as well.
";C:\Program Files\Java\jdk1.6.0\bin" sometime you may forget to put semicolon on last existing path.
If you added it in the control panel while your command prompt was open, that won't affect your current command prompt. You'll need to exit and re-open or simply do:
By way of checking, execute:
from your command prompt and let us know what it is.
Otherwise, make sure there is a javac in that directory by trying:
from the command prompt. You can also tell which executable (if any) is being used with the command:
This is a neat trick similar to the
which
and/orwhence
commands in some UNIX-type operating systems.I know this may not be your specific error, but I once had a leading space in my path and java would work but javac would not.
For what it's worth, I offer the sage advice: "Examine your Path closely".
Ensure you don't allow spaces (white space) in between paths in the Path variable. My problem was I had white space in and I believe Windows treated it as a NULL and didn't read my path in for Java.
I faced the exact same problem that java would work but javac would not on a cmd prompt in Windows 8.
The problem occured because I forgot to remove
'>'
at the end of the path name, i.e., it was like this:where it was suppose to be like this: