In this tutorial I will explain how to add the java/javac command to the command line, this will enable you to execute any java file by simply issuing the java command, as below:

I am assuming you have installted both the Java Runtime Enviroment (JRE) and the Java Development Kit (JDK), to allow us to run the java/javac command wherever we are on the system we need to add the java and javac directorties to the systems PATH variable. To do this simply right click My Computer and select Properties, you will be met with the below screen:

From here select the Advanced tab and then push Enviroment Variables at the bottom of the window, you will be met with the below screen:
If you already have the PATH variable, simple ammend the string with the installation of the JRE/JDK, for example mine is as follows.
C:\Program Files (x86)\Java\jdk1.6.0_22\bin; C:\Program Files (x86)\Java\jre6\bin
Simply use your own installation paths, and the system will now be able to use the Java/Javac commands from anywere on the system