In java, a package can be made up of many .class files, and it is easy for this situation to become confused due to the number of classes that can be included in the package. In order to address this, the convention has developed to group all .class files for a particular package into a single directory. So in this way you can take advantage of the hierarchical file structure of the operating system. The benefit of grouping the package files into a single subdirectory is that it creates unique package names, and second is facilitating finding classes that can be buried in a directory structure.

We do this by encoding the path of the location of the .class file into the name of the package. The convention normally used is to reverse the order of the domain name of the organization or person creating the classes, then the taxonomy of the class. So if it is a class or classes related to the web layer, you might have the following package name, com.acme.myapp.web.

The second part of this trick is resolving the package name into a directory on your machine, so that when the Java program runs and it needs to load the .class file, it can locate the directory where the .class file resides.