Previous | Next | Trail Map | Writing Java Programs | Objects, Classes, and Interfaces


The Java Packages

Eight packages comprise the standard Java development environment.

The Java Language Package

The Java language package, also known as java.lang, contains classes that are core to the Java language. The classes in this package are grouped as follows:
Object
The granddaddy of all classes--the class from which all others inherit. This class was covered previously in this lesson in The Object Class.
Data Type Wrappers
A collection of classes used to wrap variables of a primitive data type: Boolean, Character, Double, Float, Integer and Long.
Strings
Two classes that implement character data. The String and StringBuffer Classes(in the Writing Java Programs trail) is a thorough lesson on the use of both types of strings.
System and Runtime
These two classes provide let your programs use system resources. System provides a system-independent programming interface to system resources and Runtime gives you direct system-specific access to the runtime environment. Using System Resources(in the Writing Java Programs trail) describes both the System and Runtime classes and their methods.
Threads
The Thread, ThreadDeath and ThreadGroup classes implement the multi-threading capabilities so important to the Java language. The java.lang package also defines the Runnable interface. Runnable makes it convenient for Java class to be active without subclassing the Thread class. Through an example-oriented approach Threads of Control(in the Writing Java Programs trail) will teach you about Java threads.
Classes
The Class class provides a runtime description of a class and the ClassLoader class allows you to load classes into your program during runtime.
Math
The Math class provides a library of math routines and values such as pi.
Exception, Error, and Throwable
When an error occurs in a Java program, the program throws an object which indicates what the problem was and the state of the interpreter when the error occurred. Only objects that derive from the Throwable class can be thrown. There are two main subclasses of Throwable: Exception and Error. Exceptions are a form of Throwable that "normal" programs may try to catch. Errors are used for more catastophic errors--normal programs should not catch errors. The java.lang package contains the Throwable, Exception, and Error classes, and numerous subclasses of Exception and Error that represent specific problems. Handling Error Using Exceptions(in the Writing Java Programs trail) shows you how to use exceptions in your Java programs to handle errors.
Process
Process objects represent the system process that is created when you use Runtime to execute system commands. The java.lang packages defines and implements the generic Process class.
The compiler automatically imports this package for you. No other packages are automatically imported.

The Java I/O Package

The Java I/O Package (java.io) provides a set of input and output streams used to read and write data to files or other input and output sources. The classes and interfaces defined in java.io are covered fully in Input and Output Streams(in the Writing Java Programs trail).

The Java Utility Package

This Java package, java.util, contains a collection of utility classes. Among them are several generic data structures (Dictionary, Stack, Vector, Hashtable) a useful object for tokenizing a string and another for manipulating calendar dates. The java.util package also contains the Observer interface and Observable class, which allow objects to notify one another when they change. The java.util classes aren't covered separately in this tutorial although some examples use these classes.

The Java Networking Package

The java.net package contains classes and interface definitions that implement various networking capabilities. The classes in this package include a class that implement a URL, a connection to a URL, a socket connection, and a datagram packet. You can use these classes to implement client-server applications and other networking communication applications. Custom Networking and Security(in the Networking trail) has several examples using these classes, including a client-server example and an example that uses datagrams.

The Applet Package

This package contains the Applet class -- the class that you must subclass if you're writing an applet. Included in this package is the AudioClip interface which provides a very high level abstraction of audio. Writing Applets(in the Writing Applets trail) explains the ins and outs of developing your own applets.

The Abstract Window Toolkit Packages

Three packages comprise the Abstract Window Toolkit: java.awt, java.awt.image, and java.awt.peer.
AWT Package
The java.awt package provides graphical user interface (GUI) elements that are used to get input from and display information to the user. These elements include windows, buttons, scrollbars, and text items.
AWT Image Package
The java.awt.image package contains classes and interfaces for managing image data, such as setting the color model, cropping, color filtering, setting pixel values, and grabbing snapshots of the screen.
AWT Peer Package
The java.awt.peer package contains classes and interfaces that connect platform-independent AWT components to their platform-dependent implementation (such as Motif widgets or Microsoft Windows controls).
Creating a User Interface(in the Creating a User Interface trail) covers all three of the AWT packages.


Previous | Next | Trail Map | Writing Java Programs | Objects, Classes, and Interfaces