|
|
A Java package is a collection of related classes that can be imported into your program to support your software. They also provide namespace management, as well as access protection.
Note | A namespace is the scope of the name of a variable. |
The following table shows some of the main packages that are included in the recent Java 1.4 SDK (Software Development Kit) release along with a brief description of what they include.
Package | Description |
---|---|
java.lang | This is the fundamental Java package containing classes essential to the Java language. This package is included in your program by default and contains many useful classes, such as String, Thread, and the primitive data type support classes. |
java.io | The I/O package contains classes that allow support for input and output operations. You can learn more about input/output in Chapter 6. |
java.awt | This is the Abstract Window Toolkit package and contains all the necessary classes to create a GUI within your Java applications and applets. |
java.awt.event | This package is used to support the Abstract Window Toolkit by containing classes for event handling. |
java.awt.image | This package provides important classes for storing and manipulating images, most notably the BufferedImage and VolatileImage classes, which we will look at in Chapter 9, "Graphics." |
javax.swing | The Swing package, as with the AWT package, is used to create a GUI. However, Swing is the newer of the two and, in our opinion, the best one to use (see Chapter 8, "Applications and Applets" for information on the differences regarding lightweight and heavyweight components). |
javax.swing.event | As with the java.awt.event package, this includes extra event handling functionality to support the javax.swing package. |
java.util | The utility package contains many useful classes, including storage classes such as ArrayList and LinkedList. We will look more into this package later in this chapter, as it is very important. |
java.net | This package contains everything you need to handle basic networking in Java. You can find out more about how to use this package in Chapter 17, "Introduction to Networking." |
java.nio | This is a new package to the 1.4 release and contains classes used to implement NIO (New I/O). More can be read about this subject in Chapter 18. |
java.sql | Finally, we have the SQL package, which gives us database support within Java. We will use this when we take a look into databases in Chapter 14. |
Although there are many other packages within the Java language, the above list is probably the most common that you will come across. Let's now take a look at how we can use and import these standard packages into our Java applications and applets.
|
|