javac compiler and the
java interpreter need a way to search your entire CLASSPATH for the classes you require in your program. The only externally visible identifier of a compiled
.class file is the filename. So the filename must be enough to find the classes you need. If there were a public class named Abc in a
.class file named Fgh.class,
javac and
java would have no way to find it.
You might ask about classes with
protected or package access. There, the directory names found in the directories in your CLASSPATH provide a visible trail to your classes.