Question

I'm trying to compile a Java source file, and get the error message "bad command or filename". What did I do wrong?

Answer

This is a VERY frequently asked question. You need to add a path statement in your autoexec.bat file on windows to allow the javac.exe program to be found.

For example, if you installed java to the c:\java\ directory, you'd add the following to autoexec.bat

set path=%path%;c:\java\bin\

Hint: change the path to your installation dir (e.g. c:\jdk1.1.7\bin)

Remember to rerun the autoexec.bat file or reboot before trying to compile again, or the path setting will not be acted upon.


Back