Reputation: 51
I was trying to understand the general hierarhcy of Java packages.
If you consult this Oracle page, it seems that there are 3 main packages:
java, javax and org.
All packages, in Java platform 7, start with one of these three.
Are these ones part of a bigger package?
I'd love to see a complete tree, but the one offered by Oracle is very confusing, because it's too detailed.
Another thing I did not undestand is why packages like "java.awt" and "java.awt.color", or "java.lang" and "java.lang.annotation", are put by Oracle on the same level.
I did read online that if you import a "parent-package", you don't import any classes form the "child-packages", and that makes sense. However, it's hard to think that there isn't a relation between java.awt and java.awt.color; It seems intuitive that the least is contained in the fromer.
So, given my current understanding, I would draw a tree that look like this:
Upvotes: 2
Views: 3814
Reputation: 10685
No, there is no "bigger" package. The structure evolved over time, with different ideas and marketing influencing the naming.
You do not import packages in java, just classes. So before Java9, it does not really matter much even in which package a class resides except for the package-protected visibility scope (which is not used that much), and the lack of need to import classes from the same package.
Often classes from a subpackage are used by classes in a parent package, but not the other way round. But there is no strict rule about this.
Upvotes: 2