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 today's 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

::How many projects are named after the company? Many Projects have their own domains.

As I said: Nice idea, at first sight.

-- MarkoSchulz

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)

I am so lucky that I have stayed in the same job for a long time and so my email address has not changed for years. It does have aliases and I discovered recently that it is aliased to the original email address I was assigned when we were first allocated codes many years ago. -- JohnFletcher
See: CreatingJavaPackages


View edit of March 8, 2012 or FindPage with title or text search