One of the first things to do when starting a new project is to choose a hierarchy of package names to represent the work that is being done.  This is not as easy as it sounds.  

The hierarchy of the packages can be the only thing that uniquely differentiates your software from any other.  The package structure is usually the reverse of the URL the software would have if it was made available on the internet - even if it is not a web application.  This is best illustrated by examples.


Package name to be used?

A global company, Hyro is writing some internal timesheet software for use by its own staff.

com.hyro.timesheet.* in the Hyro source code repository

A global company, Hyro is writing an application on behalf of a local Australian company, Bright Brewery.* in the Hyro source code repository.  This package structure would be used even if the resulting product was not for use on the Internet.

So, the prefix for the package names are standardized:




All default java code libraries published by Sun Microsystems.  Unlike the early days of C and C++, this codebase usually consists of rock-solid code and clearly designed APIs.  Off limits.


Community code, generally provided free for all to use as open source.


Similar to org.* this code is usually for community open source projects.


Commercial/company code, usually owned by a company.


All software written for a particular company.  “thecompany” is usually the one paying for the software to be written.


All software for the project exists beneath here.  For example, common utilities for the entire project would be placed in com.thecompany.theproject.util*

Strictly Australian-only companies would have at the beginning.*

For community Australian-only organisations.  Etc.

Avoid naming packages with a plural meaning; don't put an 's' on the end.  For example – if you have a package for “models”, rename it to “model”, much like the java.util package.  The existence of the package implies plurality so the 's' is pointless.

Trap! Package names never have upper case letters in them, even where two words are joined together.  Numbers should generally not be used as part of package names.

blog comments powered by Disqus