In JRE, Sun's internal packages are prefixed with 2 top-level domains (sun and com). For example,
com.sun.security.jgss
sun.security.jgss
It seems pretty random to me which prefix they choose. I am curious what rules Sun uses for this.
In JRE, Sun's internal packages are prefixed with 2 top-level domains (sun and com). For example,
com.sun.security.jgss
sun.security.jgss
It seems pretty random to me which prefix they choose. I am curious what rules Sun uses for this.
The "com.sun" convention is the more preferable format because it follows the "naming conventions" that have been established for naming Java packages.
http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html
You're supposed to use your unique company or personal website URL as the first few words in the package to guarantee uniqueness in the namespace. The ones that start with "sun" were probably not intended to be exposed to the outside world.
If you take a glance at the compatibility document for Java 5 you'll notice that there are other reasons too:
Apache - The org.apache classes, which have never been supported J2SE APIs but are used by the javax.xml package, have moved in 5.0 to com.sun.org.apache.package.internal so that they won't clash with more recent, developer-downloaded versions of the classes.
Any applications that depend on the org.apache classes being part of the J2SE release must do one of the following to work in 5.0:
* Code the application so it uses only the supported interfaces that are part of JAXP.
* Download the org.apache.xalan classes from Apache.
Not an answer to the question, but please be aware that you should not use 'sun' or 'com.sun' packages in your programs directly.
See Why Developers Should Not Write Programs That Call 'sun' Packages
Those packages are not part of the public API of the standard Java library, and using them might make your program incompatible with future versions of Java or implementations of Java other than the Sun implementation (and there are several implementations by other vendors, including Apple, IBM and HP).