I own a .co.uk domain, and I whenever I've dealt with Java-style package naming, I've gone with uk.co.domainname. Once I encountered package that did the following: co.uk.domainname.

Is one of these right, or is it something that's up to the developer's discretion? Is there some sort of convention that deals with this?


2 Answers 2


There's no real rule here, just the conventions that Sun created with the com.sun.* packagers. The only real requirement is uniqueness and that the co.uk... convention defines a folder/file structure.

What will be the decider in your case is what name you want for a 'root' folder - 'uk' or 'co'?

  • Thanks, that sounds fair enough. Though having packages with both co.uk.* and uk.co.* in the same project does seem very.. messy.
    – Andrey
    Dec 16, 2012 at 10:04
  • Right - whatever you choose, be consistent. (Not being consistent with package naming can cause real headaches, like java files split into different roots, issues with testing protected methods, etc,) Dec 17, 2012 at 4:02
  • I meant specifically when you have to use a third-party package and it uses co.uk.* while you're using uk.co.*. In which case I guess it's purely cosmetic.
    – Andrey
    Dec 17, 2012 at 6:53

Java tutorials make it pretty clear that you should use the inverse of your domain name, e.g. uk.co.domainname. If you mix it up and go with co.uk.domainname then you run the risk of someone with the site http://uk.co clashing with your package naming structure. While unlikely, you may as well stick to the standards and rule any potential clash out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.