Objects, Classes, and Interfaces |
Eight packages comprise the standard Java development environment.The Java Language Package (notes)
The Java language package, also known asjava.lang
, contains classes that are core to the Java language. The classes in this package are grouped as follows:The compiler automatically imports this package for you. No other packages are automatically imported.
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
andLong
.- Strings
- Two classes that implement character data. The String and StringBuffer Classes is a thorough lesson on the use of both types of strings.
System
andRuntime
- These two classes provide let your programs use system resources.
System
provides a system-independent programming interface to system resources andRuntime
gives you direct system-specific access to the runtime environment. Using System Resources describes both theSystem
andRuntime
classes and their methods.- Threads
- The
Thread
,ThreadDeath
andThreadGroup
classes implement the multi-threading capabilities so important to the Java language. The java.lang package also defines theRunnable
interface.Runnable
makes it convenient for Java class to be active without subclassing theThread
class. Through an example-oriented approach Threads of Control will teach you about Java threads.- Classes
- The
Class
class provides a runtime description of a class and theClassLoader
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
, andThrowable
- 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 ofThrowable
:Exception
andError
. Exceptions are a form ofThrowable
that "normal" programs may try to catch. Errors are used for more catastophic errors--normal programs should not catch errors. Thejava.lang
package contains theThrowable
,Exception
, andError
classes, and numerous subclasses ofException
andError
that represent specific problems. Handling Error Using Exceptions 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 useRuntime
to execute system commands. Thejava.lang
packages defines and implements the genericProcess
class.The Java I/O Package (notes)
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 injava.io
are covered fully in Input and Output Streams.The Java Utility Package (notes)
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. Thejava.util
package also contains theObserver
interface andObservable
class, which allow objects to notify one another when they change. Thejava.util
classes aren't covered separately in this tutorial although some examples use these classes.The Java Networking Package (notes)
Thejava.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 has several examples using these classes, including a client-server example and an example that uses datagrams.The Applet Package (notes)
This package contains theApplet
class -- the class that you must subclass if you're writing an applet. Included in this package is theAudioClip
interface which provides a very high level abstraction of audio. Writing Applets explains the ins and outs of developing your own applets.The Abstract Window Toolkit Packages (notes)
Three packages comprise the Abstract Window Toolkit:java.awt
,java.awt.image
, andjava.awt.peer
.Creating a User Interface covers all three of the AWT packages.
- 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).
Objects, Classes, and Interfaces