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

17,334

Solution 1

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".

Solution 2

Its not necessary that it always start with .com.

What is it exactly?

Its actually package naming convension.

How to decide root package name?

Generally we android developer having practice to decide package name based on the domain name of a particular company.

For example:

  1. Domain name: sun.com => Root package name something like : com.sun
  2. Domain name: technotalkative.com => Root package name something like: com.technotalkative.android
  3. Domain name: sun.org => Root package name something like: org.sun.androidapp

For more information, check: What should be the package name of android app?

Solution 3

Because it's sun.com and the vast majority of packages come from a company. For apache.org packages, the root is org, and so on. It's just a reverse (canonical) domain name namespace.

Share:
17,334

Related videos on Youtube

Umar Khan
Author by

Umar Khan

Updated on October 04, 2020

Comments

  • Umar Khan
    Umar Khan over 3 years

    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?