Assuming you have downloaded and installed the JDK,
Open your main menu, and right click on Computer/My Computer, click properties. If you're running Vista you may need to authorize yourself and click "Advanced System Settings".
in the "advanced" tab of the dialog that appears, click the button that says "Environment Variables". This is where you set up the programs that can be run through command prompt, i.e. notepad or mspaint. Locate the variable "Path" (cases may vary) in side the "System Variables" group, and click Edit after you've selected it.
In the text box labeled "Variable value", you will be confronted with a bunch of paths. These are the locations of the programs you want to run via command prompt, i.e. Notepad, Outlook, or in your case, Java/Compiler.
This is what my "path" looks like:
Code:
C:\Program Files\Microsoft DirectX SDK (August 2007)\Utilities\Bin\x86;C:\Program Files\Microsoft DirectX SDK (November 2007)\Utilities\Bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Autodesk\Backburner\;C:\Program Files\Common Files\Autodesk Shared\;C:\MinGW\bin\; C:\Qt\4.3.4\bin;C:\Progra~1\Notepad++;C:\Program Files\Common Files\Adobe\AGL
Every path is separated by a semi-colon, so add a semi-colon to the end of your current path, and find the location of your Java SDK. The most common place to look is C:\Progra~1\Java (C Drive->Program Files->Java). Once you've located your Java SDK, open the "bin" directory, copy the path from your address bar, and place it after the semi-colon you placed at the end of "Variable value". Click OK and close any remaining dialogs, and you now have your paths set up, so you will be able to run Javac (C:\Progra~1\java\<jdk version>\bin\Javac.exe) from the terminal/command prompt.
For linux, there is a simple command called "export" in the terminal that can do all of this for you. I bet you're using Windows though.