Javac is not recognized as an internal or external command

Just to clarify the most commont and annoying problem that newbie Java-developer faces is the inability to compile .java files on the fly from windows command line. So to fix this

  1. Open console (Windows-run "cmd")
  2. Type "set" - this will list all of windows global variables. We are interested in Path variables since it allows to run applications without specifying full path all the time - operating system simply tries all of these paths
  3. Now we'll append this path with path to Java Development Kit (don't confuse with Java Runtime Enviroment) and it should look like this:

C:\foo\bar\> set PATH=%PATH%;C:\j2sdk1.4.2_01\bin C:\foo\bar\> javac Filename.java

Other ways you can do same thing is from GUI, but how you do it varies from OS — its Computer / Properties / Advanced settings in WindowsXP and Command panel / User Accounts / Change my enviroment variables in Vista

RSS