Name of the file should be same as class name (just a norm, works otherwise).
Compile your .java source file to generate a .class file
javac-d<destinationof.classfiles>sourcefile.java
.class file will have same name as class.
javac here is java compiler.
Go to destination folder which contains .class file and run following command.
javafilename
Actually filename will be filename.class but we write without .class
java here is application launcher
Note that jvm looks for public static void main(String[] variable) and not the compiler.
Hence, when you do not mention this main function and compile program, it does not give you compile-time error. But when you run it without main run-time error is obtained.