Error message "Public class ClassName must be defined in a file called ClassName.java" indicates that the file name does not exactly match the name of the public class in the file or that you typed the class name incorrectly when compiling the class.
To avoid this error go to folder option-->Under view tab uncheck "Hide extension for known file type" option. Now rename ur file as Filename.java