org. is commonly (though not always) used for open source projects because they are released in a not-for-profit way. However, within companies you will find a lot of code using com.companyname, or even just companyname. or projectname. (the latter two styles are not recommended.) So I don't think it's true that "most people" use org - that's just what it looks like because you can't see all of that private company code on the Internet!
The reason for all this is that Sun, the company that created Java, recommends that people put classes in packages named after their domain name, reversed, and create subpackages within that to be unique within their organisation. The purpose is to avoid name clashes. That is why apache packages start with org.apache, for example - because apache's main domain name is apache.org.
发布评论
评论(2)
令人惊奇的是像“java 包命名约定" 可以在
由维基百科。
包
包名称
It is amazing what a simple search like "java package naming conventions" can yield in Google.
by Wikipedia.
Package
Package Names
组织。通常(尽管并非总是)用于开源项目,因为它们以非营利方式发布。然而,在公司内部,您会发现很多代码使用 com.companyname,甚至只是公司名称。或项目名称。 (不推荐后两种样式。)所以我不认为“大多数人”使用 org 是正确的 - 这只是它看起来的样子,因为你无法在互联网上看到所有私人公司代码!
造成这一切的原因是,创建 Java 的 Sun 公司建议人们将类放入以其域名命名的包中,反转后,并在其中创建子包,以使其在组织内是唯一的。目的是避免名称冲突。这就是为什么 apache 包以 org.apache 开头——因为 apache 的主域名是 apache.org。
org. is commonly (though not always) used for open source projects because they are released in a not-for-profit way. However, within companies you will find a lot of code using com.companyname, or even just companyname. or projectname. (the latter two styles are not recommended.) So I don't think it's true that "most people" use org - that's just what it looks like because you can't see all of that private company code on the Internet!
The reason for all this is that Sun, the company that created Java, recommends that people put classes in packages named after their domain name, reversed, and create subpackages within that to be unique within their organisation. The purpose is to avoid name clashes. That is why apache packages start with org.apache, for example - because apache's main domain name is apache.org.