Java packages com and org

JavaPackage

Java Problem Overview


What are the meaning of the packages org and com in Java?

Java Solutions


Solution 1 - Java

According to http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html">Sun</a>;, packages should be namespaced according to the inverse of your domain name, and then followed by whatever you see fit. Most companies or organisations have a .com, or .org domain name, and hence most packages start with com. or org.. To quote from the http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html">Sun Code Conventions:

>The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981. > >Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names.

And the examples that they give, make it pretty clear that you are meant to use the companies DNS name:

> com.sun.eng > > com.apple.quicktime.v2 > > edu.cmu.cs.bovik.cheese

You will also see edu. and net. packages out http://pmd.sourceforge.net/ant-task.html">in the wild as well, although they are less common.

Solution 2 - Java

You can also see package names as reversed internet domain names (which is often also true in real world, see for example the org.apache.commons which correlate with http://commons.apache.org). The com (commercial) and org (organization) are here then actually Top Level Domain names.

Package names are in general just to identify the manfacturer/vendor of the code you're facing.

Solution 3 - Java

Usually com is used by companies when naming the packages, com being followed by the company's name. For instance you have the com.sun packages in the JVM.

The org package prefix is mostly used by non-profit organizations or for open source code, such as apache, w3c, etc.

Solution 4 - Java

See Oracle doc for package naming

See Naming Conventions for class/interface/annotations/etc standard naming

> package name and class standard syntax:
> <your domain in reverse>.<project name>.<controller/dao/service/handlers etc>.<your class>

example1: (here domain:- "stackoverflow.com", project:- "Test")
com.stackoverfllow.test.handler.TestHandler

example2: (here domain:- "www.google.co.in", project:- "My Proj")
in.co.google.myproj.controller.MainController

> but for reserved domains like java.*, javax.*, sun.*, etc. you should > get permission from oracle community

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGabrielView Question on Stackoverflow
Solution 1 - JavaPaul WaglandView Answer on Stackoverflow
Solution 2 - JavaBalusCView Answer on Stackoverflow
Solution 3 - JavaGuillaumeView Answer on Stackoverflow
Solution 4 - JavaDharmendrasinh ChudasamaView Answer on Stackoverflow