The standard way to avoid package name conflicts in Java is to use the reverse domain agreement com.[mycompany].[rest-of-the-package-name]
. It works brilliantly ... if someone owns the [mycompany] .com domain.
However, there are several individual developers (or students) who:
- You cannot (or cannot afford) to own a domain
- Still create package names, hoping they will be unique.
This only introduces the scope of packet conflicts.
Next, suppose I have [mycompany] .com. What prevents a developer from creating a library with the same package prefix as mine and distributing it? AFAIK, there is no legal binding to package names ("you MUST own the domain that you used in your Java package"). Not to mention that this action on the developer part may not be intentional (how many of us comb the web page to find a non-existent domain name before we name our packages?).
Also, even if I have a domain name, it may or may not be suitable for use as a package name (my domain name may include hyphens, or it may be so long that, although this is the name of a legal package, it can still make it impractical).
So my question is: how can I make a unique Java package name?
source share