Java Reference
In-Depth Information
Java's Class Library
A library in Java is a collection of classes - usually providing related facilities - which you can use in
your programs. The Java class library provides you with a whole range of goodies, some of which are
essential for your programs to work at all, and some of which make writing your Java programs easier.
To say that the standard class library covers a lot of ground would be something of an understatement
so we won't be going into it in detail here, but we will be looking into how to apply many of the
facilities it provides throughout the topic.
Since the class library is a set of classes, it is stored in sets of files where each file contains a class
definition. The classes are grouped together into related sets that are called packages , and each package
is stored in a separate directory. A class in a package can access any of the other classes in the package.
A class in another package may or may not be accessible. We will learn more about this in Chapter 5.
The package name is based on the path to the directory in which the classes belonging to the package are
stored. Classes in the package java.lang for example are stored in the directory path java\lang (or
java/lang under Unix). This path is relative to a particular directory that is automatically known by the
Java runtime environment that executes your code. You can also create your own packages that will contain
classes of your own that you want to reuse in different contexts, and that are related in some way.
The SDK includes a growing number of standard packages - well over 100 the last time I counted.
Some of the packages you will meet most frequently are:
Package Name
Description
java.lang
These classes support the basic language features and the handling of
arrays and strings. Classes in this package are always available directly in
your programs by default because this package is always automatically
loaded with your program.
java.io
Classes for data input and output operations.
java.util
This package contains utility classes of various kinds, including classes for
managing data within collections or groups of data items.
javax.swing
These classes provide easy-to-use and flexible components for building
graphical user interfaces (GUIs). The components in this package are
referred to as Swing components.
java.awt
Classes in this package provide the original GUI components (JDK1.1) as
well as some basic support necessary for Swing components.
java.awt.geom
These classes define 2-dimensional geometric shapes.
java.awt.event
The classes in this package are used in the implementation of windowed
application to handle events in your program. Events are things like
moving the mouse, pressing the left mouse button, or clicking on a menu
item.
Search WWH ::




Custom Search