Reputation: 6338
I'm a beginner in programming web apps with Java EE. How do you name your packages?
I often saw stuff like com.abc.commons... is there a standard or a common way to do that?
Thanks to seanizer, I gonna use your approach: com.mycompany.myproject.api
Upvotes: 4
Views: 3318
Reputation: 299218
These parts usually enter into my package names
example:
com.mycompany.myproject.api.services
// contains service interfaces for project myproject
com.mycompany.myproject.common.util.string
// contains string-related utility classes that reside in a library module
// that will be used by several other artifacts
One good practice is to have a common root package that is distinct for an individual project (jar etc). For example: in the jar myproject-api.jar , the root package would be com.mycompany.myproject.api
. That way you always know where to find your classes.
Upvotes: 7
Reputation: 75426
The customary way is to do your own domain backwards, as this is a pretty good guarantee that others do not accidentially use those package names.
Upvotes: 0
Reputation: 116306
Yes, see the Sun Naming Conventions.
The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.
Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names.
Examples:
- com.sun.eng
- com.apple.quicktime.v2
- edu.cmu.cs.bovik.cheese
Upvotes: 2