The standard way to avoid package name conflicts in Java is to use reverse-domain convention com.[mycompany].[rest-of-the-package-name]
. This works brilliantly ... if one owns the domain [mycompany].com.
However, there are several individual developers (or students) who:
- Don't (or can't afford to) own a domain
- Still conjure up some package names hoping they will be unique.
This alone introduces scope for package conflicts.
Further, assume that I own [mycompany].com. What is preventing a developer from creating a library with the same package prefix as mine and distributing it? AFAIK, there is no legal binding with regard to package names ("you MUST own the domain which you have used in you Java package"). Not to mention that this action on the developer's part might not be intentional (how many of us comb the web looking for a non-existent domain name before we name our packages?).
Even further, even if I own a domain name, it may or may not be suitable for use as a package name (my domain name could include hyphens, or it could be so long that although it is a legal package name, it could still make it impractical).
So my question is: How do I really make my Java package name unique?