To compile a Java program, the file has to be saved ClassName.java, where ClassName is the name of the class in the file. In the command prompt change the directory to whatever directory your program is in. Type javac *.java (you can insert the name of the file or leave the wildcard and it will compile everything in the folder). Then to run the program, type java ClassName
To use the javac and java commands, you need to have downloaded the jdk from sun.com.
Hope this helped.