Google+

214. Understanding the Packages in Java API







Pre-requisite -
Java API is categorized using the packages at different levels of hierarchy. In order to understand it, lets go through the below steps -

1. Open the web page http://docs.oracle.com/javase in any browser as shown below - 


2. Select 'Java SE API Documentation' link in the page as shown below -


3. Observe that Java SE 8 API Documentation page is displayed as shown below -


4. In Packages section of Java API, view the packages which starts with java.awt as shown below -



5. All the packages which start with java.awt are the sub-packages of  'awt' package as shown below -


6. awt is the sub-package of java package as shown below -


7. So packages when saved in computer form the folders, hence we can represent the folder structure of java.awt.color as -

color folder is inside the awt folder
awt folder is inside the java folder

8. But java package is at the top level in the Java API package hierarchy having the sub-packages like awt, beans etc as shown in the below screenshot -


9. All the sub-packages of java packages say awt, will have their own sub-packages as shown in the below screenshot -


10. Hence packages in the Java API are organized at different level. I have represented sample collection of packages using their hierarchy as shown below  -

 

In the above screenshot -

- java package is at the top level in the hierarchy
- applet, awt, io, lang, beans, etc packages are the sub-packages of java package
- For exampe the sub-package awt package has its own sub-pakcages  like color, data transfer etc
- The sub-package of awt package i.e. image has its own sub-package renderable

Hence in this manner all the packages in Java API are categorized at different levels. And all the Classes in Java API are organized properly under the above categorized packages.

Hope your understood the importance of packages in Java API architecture.





Please comment below to feedback or ask questions.

Renaming the packages in Hierarchy will be explained in the next post.








No comments:

Blog Index