views:

1022

answers:

2

I'm trying to use javac with the windows command prompt, but its not working.

After adding the directory "C:\Program Files\Java\jdk1.6.0_16\bin\" to the end of the environment path variable, the java command works fine, but using javac gives me the error:

'javac' is not recognized as an internal or external command, operable program or batch file.

Any ideas? Thanks.

+3  A: 

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:

set path="%path%;c:\program files\java\jdk1.6.0_16\bin"

By way of checking, execute:

echo %path%

from your command prompt and let us know what it is.

Otherwise, make sure there is a javac in that directory by trying:

"c:\program files\java\jdk1.6.0_16\bin\javac.exe"

from the command prompt. You can also tell which executable (if any) is being used with the command:

for %i in (javac.exe) do @echo %~$PATH:i

This is a neat trick similar to the which and/or whence commands in some UNIX-type operating systems.

paxdiablo
ah yes, all i had to do was re-open the command prompt and it worked fine, thanks!
Domenic
+1. The "for %i in (java.exe) do @echo %~$PATH:i" just saved my day. I'm just a occasional Windows user and I just did not know there's could be yet another hidden java.exe in c:\windows\system :)
david a.
A: 

Give it as "C:\Program Files\Java\jdk1.6.0_16\bin". Remove the backslash it will work

valli
I don't think that's correct. I can set my path to be nothing but "C:\Program Files\Java\jdk1.6.0_16\bin\" (with trailing slash) and it still works fine.
paxdiablo