Results 1 to 1 of 1
Thread: Conventions with Package Naming
- 11-13-2011, 07:58 PM #1Member
- Join Date
- Nov 2011
- Rep Power
Conventions with Package Naming
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.
- By javajosh in forum New To JavaReplies: 4Last Post: 11-01-2011, 05:52 AM
- By gib65 in forum New To JavaReplies: 8Last Post: 08-05-2010, 04:24 AM
- By tim in forum Forum LobbyReplies: 10Last Post: 11-16-2008, 10:27 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 12-03-2007, 10:53 AM
- By money123 in forum New To JavaReplies: 3Last Post: 07-31-2007, 05:44 AM