Java Package Names

Standards for Java package names

If you have your own domain

Start your package names with your domain, reversed. For example, since Ward's domain is, his packages would all start with com.c2.

If you don't have your own domain

Start your package names with your email address, reversed. For example, since my email address is, my package names would all start with com.sprintmail.wconrad.

Or, host your code at a site which will give you a slice of their domain. For example, if I were to host my code at, then my packages would start with org.gjt.wconrad.

Note that sourceforge ( has now given permission for Java developers to use com.sourceforge.<project> as the package name.

Shouldn't that be net.sourceforge.<project>?

In particular, Sec. 7.7 of the Java Language Specification doesn't say anything about email address, but it is a good convention.

Actually, it motivates people to register domain names for their projects. I own primarily for the purpose of having a nice Java package name for my pet project. -- OlafKummer

I always thought that this pattern for generating package names is shortsighted. It looks nice first, but cannot really carry you through. How for example should todays regular mergers and renamings of companies be handled? Touch all sources? Or leave them and try to remember whether you have to use com.daimler, or com.daimlerchrysler? And Sun did not hold onto it from the beginning too: Or how should they own the top level domains .java and .javax? And what should happen if there would be TLDs .java and .javax in the future and somebody actually has the domain

As I said: Nice idea, at first sight.


Complaining is easy. What's your proposal?

How about:

 package md5.b0aafe05fc46ae69dca469ec10fc353b ;

HaHaOnlySerious - think MicroSoft CLSIDs.

A better solution might be to allow aliasing - for instance, when Foo Corp buys Bar Systems, they set up an alias from to, or move the code from to and set up an alias under (or whatever - this would probably be too broad). Where the code is in JAR files (a fairly common case), this could be done with entries in the META-INF directory. The compiler might consider aliased names to be deprecated, and so warn programmers when they used them. Note that this would also have eased the pain of the SwingNamespaceTransition?.

The problem of name change over time is more serious for email addresses; i used to be, now i'm, and soon i'll probably be Meanwhile, i am also (my account on the bioinformatics BigIron), and a variety of other names, none of which are really permanent. The TagUri approach could solve this problem.

-- TomAnderson (OpenAuthor; signing to make clear it's not MarkoSchulz writing)

See: CreatingJavaPackages

EditText of this page (last edited April 5, 2005)
FindPage by browsing or searching

This page mirrored in JavaIdioms as of April 29, 2006