Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the root package in source code called "com"? [duplicate]

Tags:

In most source codes, the root package/folder is named "com". Why is that so? It it just convention or does it stand for something?

like image 320
Umar Khan Avatar asked Jan 06 '11 21:01

Umar Khan


People also ask

What is the COM in package naming?

It's the domain name spelt out in reverse. For example, one of my domains is hedgee.com. So, I use com. hedgee as the base name of all my packages.

What is COM package in Java?

So com. prefix in package names means the same as .com suffix in domain names: "commercial".

Should Java package names be plural?

Yes perfectly acceptable to have plurals, look at Collections for example, it is a class which has many static methods which help when dealing with different flavours of collection.

What is package name in Java?

A package in Java is used to group related classes. Think of it as a folder in a file directory. We use packages to avoid name conflicts, and to write a better maintainable code. Packages are divided into two categories: Built-in Packages (packages from the Java API)


1 Answers

The convention is that a programmer in a given organization will start package names with their organization's domain name, as a unique identifier -- in reverse order. This prevents namespace clashes between code from different organizations (within the organization you're on your own).

So if I work for a company called Supercompany, and their domain is supercompany.com, all of my package names will start with com.supercompany. And since a lot of code is written for companies, a lot of packages start with com. However, there are plenty of packages that start with "net" or "org" or other such top-level domains. Myself, I work for a university, so my package names generally start with "edu".

The brief answer, then, is that most package names start with "com" because most domain names end with "com".

like image 75
Jacob Mattison Avatar answered Oct 18 '22 06:10

Jacob Mattison