This is almost definitely caused by not having your java bin in your path. Assuming windows because of the error you gave...
Go to wherever you installed java. The default is C:\Program Files\Java\jdk1.6.0_07 if you're using the updated version at the time of this posting. Make sure that this directory has a bin subdirectory, and that that bin subdirectory has java, javac, and all those other exe/bat files in there.
THEN add that bin directory to your PATH environment variable.
Start > Right click "My Computer" > Properties > Advanced Tab > Environment Variables > find PATH in the lower section and press Edit, and append C:\Program Files\Java\jdk1.6.0_07\bin to the end of that string (adjust as necessary).
NOW, open up cmd and if you type "echo %PATH%" the java bin should show up, and when you type java or javac it will be recognized as a command
-------
"Don't bail; the best of the gold is at the bottom of the barrels of crap."
-- Randy Pausch