Just right click on MyComputer goto Properties..Click the Advanced Tab..and click the Environment Variables button..Click New button under UserVariable option then set the name as JAVA_HOME and value as /home/where/your/jdk_is/.. Then try to compile the program..it works..If you still face then just navigate to your bin folder of jdk and try compile your program....
Never try to be a hard-worker. Be a smart-worker.
Very common problem; we have all had it. Why are you using Java1.4.2, which was superseded nearly 4 years ago? Go back to the Sun website and download the latest stable version, which came out this week, and you will find it called JDK 6 update 7. Install that as usual, and as you go, watch very closely for the name of the folder Windows installs it into. It says "Install into C:\Program Files\java\jdk1.6.0_07 or choose another folder" and most people use the default option, but remember the name of the folder.
Now navigate to this page in the Java Tutorials and you will see your problem at the top of the page. Read that. You see you have to update your PATH variable. On the page there is a link to the installation instructions. It says "update the PATH variable (optional)". Never mind about "optional"; do exactly what it says about updating PATH permanently. There is no need to do anything with the classpath. Remember:
The PATH variable you want begins with C: (usually) and ends with bin (always).
The tiniest spelling error will stop it working.
Your computer will find the "javac.exe" program in the first Java folder it finds in the PATH, so it is best only to have one Java folder in the PATH.