Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Why are URLs in package names written in reverse? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why are URLs in package names written in reverse?" Watch "Why are URLs in package names written in reverse?" New topic

Why are URLs in package names written in reverse?

joseph corner
Ranch Hand

Joined: Feb 20, 2004
Posts: 50
The title says it all
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

It's just a convention. Its not mandatory. But, I'm glad to know more regarding this

(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

I don�t know if this is the official answer, but it just makes sense from a directory standpoint, and as a �drilldown� methodology of taking a larger set, and refining it to a smaller subset. Using this naming convention, when a company or group has multiple packages, you cut down on the number of directories needed:
For example, given the packages:
you have

Here you have 6 total directories; if you went the other way:

This results in 14 directories and is a lot more confusing to find things. It is just a nature sorting order to go from the item with the largest quantity to the smallest. Personally, I�ve always felt that it is the URL�s that have it backwards
joseph corner
Ranch Hand

Joined: Feb 20, 2004
Posts: 50
Well, it's a fairly trivial question, and I know it's just a convention, but I'm interested in case there's more than meets the eye.
I don't see why with your example you couldn't have foo as the top directory, followed by com, followed by the various subdirectories.
It seems more readable to me. Have I missed something?
[ February 25, 2004: Message edited by: joseph corner ]
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
I always thought the most basic reason for assigning package names as reverse URL domains is that they become unique to the organisation or individual who uses that URL. That way you only have to worry about other people in your organisation writing packages with the same name because no-one else outside your colleagues should be using your URL to name their package.
Reversing it completely does seem the most systematic way of doing it to me as it creates a more pure hierarchy.

SCJP 1.4,
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

You would have the root of the name in the middle:

This shall be the graph for your naming:;;
or standard:;;

There are domains like
which lead to:;
but where would you search the net, if it was:;
You might search at the above mentioned place, for c1, or at
for uk.c1;
sever oon
Ranch Hand

Joined: Feb 08, 2004
Posts: 268
If you think about it, URLs do, by convention, have the root web address backwards. Look at the URL
So if you think about it, the pattern the URL follows is <site>/<directory>/<more specific directory>/'s just that, by convention, the site components are listed in reverse.
I agree. Here's the link:
subject: Why are URLs in package names written in reverse?
It's not a secret anymore!