I’m writing this short guide for reference. This is only applicable for Windows 2000, XP Home/Pro and 2003. I’m still digging how to do this in Linux though. :P
To get started, by default you cannot use javac on the console / ms-dos, that is because the java compiler is part of jdk directory structure and is not added automatically in windows system path. Typically you want to compile anywhere in your machine, so you may want to add the jdk bin directory to your system path.
In order to do that, right click My Computer and click Properties. Go to (1) Advanced tab and click (2) Environment Variables. Then add new user variable by clicking (3) New. Supply the variable name “path” and the variable value. If you are using J2SE 5.0 Update 5, the default would be “C:\Program Files\Java\jdk1.5.0_05\bin\”. Use the exact path where you installed the JDK. For reference, use the figure below.
Now, you can compile your Java code anywhere. This is applicable for single user only. If you are going to logon in a different username on the same machine, then you have to repeat this process again. Please, be careful NOT to delete or edit the default system path. You don’t want your PC to screw up, so be careful.