Copyright ©1996, Que Corporation. All rights reserved. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 West 103rd Street, Indianapolis, IN 46290 or at support@mcp .com.

Notice: This material is excerpted from Special Edition Using Java, ISBN: 0-7897-0604-0. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.

Appendix B- Java API

by Michael Afergan

This appendix is designed to provide you with a detailed summary of the Java Application Programming Interface (API). The Java API is a set of classes developed by the authors of the Java language designed to assist you in developing your own classes, applets, and applications.

The classes in the Java API are grouped into packages each of which may have several classes and interfaces. Furthermore, each of these items may also have several properties such as fields and/or methods.

While it is possible to program in Java without knowing too much about the API, every class that you develop will be dependent on at least one class within the API. Consequently, when you begin to develop more complex programs that deal with strings, sockets, and graphical interfaces, it extremely helpful for you to know the objects provided to you by Sun as well as the properties of these objects.

The following appendix lists all objects defined in the Java API along with their superclass, interfaces, methods, and fields when applicable. There are however, a few details to note:

Finally note that this information (as well as explanations of each field and method) is also available in summarized form at http://www.javasoft.com/JDK-1.0/api/packages.html, or you can download and peruse the Java source code itself from http://www.javasoft.com/.

java.applet

Although the smallest, this package is the most notable as a result of the Applet class. Full of useful methods, the Applet class lays the foundation for all applets and is able to provide you with information regarding the applet's surroundings via the AppletContext interface.

Classes

Applet extends java.awt.Panel

Methods

Interfaces

AppletContext

Methods

AppletStub

Methods

AudioClip

Methods

java.awt

The Java Abstract Window Toolkit (AWT) consists of resources to enable you to create rich, attractive, and useful interfaces in your applets. The AWT not only contains managerial classes such as GridBagLayout, but also has sever concrete interactive tools such as Button and TextField. More important, however, is the Graphics class which provides you with a wealth of graphical abilities, including the ability to draw shapes and display images.

Classes

BorderLayout implements LayoutManager

Methods

Button extends Component

Methods

Canvas extends Component

Methods

CardLayout implements LayoutManager

Methods

Checkbox extends Component

Methods

CheckboxGroup

Methods

CheckboxMenuItem extends MenuItem

Methods

Choice extends Component

Methods

final Color

Fields
Methods

abstract Component implements ImageObserver

Methods

Container extends Component

Methods

Dialog extends Window

Methods

Dimension

Fields
Methods

Event

Fields
Methods

FileDialog extends Dialog

Fields
Methods

FlowLayout implements LayoutManager

Fields:
Methods

Font

Fields
Methods

FontMetrics

Fields
Methods

Frame extends Window implements MenuContainer

Fields
Methods

abstract Graphics

Methods

GridBagConstraints implements Cloneable

Fields
Methods

GridBagLayout implements LayoutManager

Fields
Methods

GridLayout implements LayoutManager

Methods

abstract Image

Fields
Methods

Insets implements Cloneable

Fields
Methods

Label extends Component

Fields
Methods

List extends Component

Methods

MediaTracker

Fields
Methods

Menu extends MenuItem implements MenuContainer

Methods

MenuBar extends MenuComponent implements MenuContainer

Methods

MenuComponent

Methods

MenuItem extends MenuComponent

Methods

Panel extends Container

Methods

Point

Fields
Methods

Polygon

Fields
Methods

Rectangle

Fields
Methods

Scrollbar extends Component

Fields
Methods

TextArea extends TextComponent

Methods

TextComponent extends Component

Methods

TextField extends TextComponent

Methods

Toolkit

Methods

Window extends Container

Methods

Interfaces

LayoutManager

MenuContainer

Methods

java.awt.image

Closely related to the java.awt package, this package consists of tools designed to handle and manipulate images coming across a network. Because all classes and interfaces in this package are closely related, you will see that many of the methods appear multiple times.

Classes

abstract ColorModel

Fields
Methods

CropImageFilter extends ImageFilter

Methods

DirectColorModel extends ColorModel

Methods

FilteredImageSource extends Object implements ImageProducer

Methods

ImageFilter implements ImageConsumer, Cloneable

Fields
Methods

IndexColorModel extends ColorModel

Methods

MemoryImageSource implements ImageProducer

Methods

PixelGrabber implements ImageConsumer

Methods

RGBImageFilter extends ImageFilter

Fields
Methods

java.awt.peer

The interfaces outlined in this package serve as intermediaries between your code and the computer on which your code is running. While it is beneficial to understand what the peers do, you probably will have no need to work directly with this package.

Interfaces

ButtonPeer extends ComponentPeer

Methods

CanvasPeer extends ComponentPeer

CheckboxMenuItemPeer extends MenuItemPeer

Methods

CheckboxPeer extends ComponentPeer

ChoicePeer extends ComponentPeer

ComponentPeer

Methods

ContainerPeer extends ComponentPeer

Methods

DialogPeer extends WindowPeer

Methods

FileDialogPeer extends DialogPeer

FramePeer extends WindowPeer

LabelPeer extends ComponentPeer

Methods

ListPeer extends ComponentPeer

Methods

MenuBarPeer extends MenuComponentPeer

Methods

MenuComponentPeer

Methods

MenuItemPeer extends MenuComponentPeer

MenuPeer extends MenuItemPeer

PanelPeer extends ContainerPeer

ScrollbarPeer extends ComponentPeer

Methods

TextAreaPeer extends TextComponentPeer

TextComponentPeer extends ComponentPeer

Methods

TextFieldPeer extends TextComponentPeer

Methods

WindowPeer extends ContainerPeer

Methods

Interfaces

ImageConsumer

Fields
Methods

ImageObserver

Fields
Methods

ImageProducer

Methods

java.io

The java.io package serves as the standard input/output library for the Java language. This package provides you with the ability to create and handle streams of data in several manners. To this end, it provides you with types as simple as a String and as complex as a StreamTokenizer. Furthermore, because this package is heavily dependant the basic InputStream and OutputStream classes as well as the interfaces, it would be a wise idea to examine their code details.

Classes

BufferedInputStream extends FilterInputStream

Fields
Methods

BufferedOutputStream extends FilterOutputStream

Fields
Methods

ByteArrayInputStream extends InputStream

Fields
Methods

ByteArrayOutputStream extends OutputStream

Fields
Methods

DataInputStream extends FilterInputStream implements DataInput

Methods

DataOutputStream extends FilterOutputStream implements DataOutput

Fields
Methods

File

Fields
Methods

FileDescriptor

Fields
Methods

FileInputStream extends InputStream

Methods

FileOutputStream extends OutputStream

Methods

FilterInputStream extends InputStream

Fields
Methods

FilterOutputStream extends OutputStream

Fields
Methods

abstract InputStream

Methods

LineNumberInputStream extends FilterInputStream

Methods

abstract OutputStream

Methods

PipedInputStream extends InputStream

Methods

PipedOutputStream extends OutputStream

Methods

PrintStream extends FilterOutputStream

Methods

PushbackInputStream extends FilterInputStream

Fields
Methods

RandomAccessFile implements DataOutput, DataInput

Methods

SequenceInputStream extends InputStream

Methods

StreamTokenizer

Fields
Methods

StringBufferInputStream extends InputStream

Fields
Methods

Interfaces

DataInput

Methods

DataOutput

Methods

FilenameFilter

Methods

java.lang

These classes are essentially the "heart" of the java language. It provides you not only with the basic data types, such as Integer and String, but also means of handling errors through the Throwable and Error classes. Furthermore, the SecurityManager and System classes supply you with some degree of control over the Java Run-Time System.

Classes

Boolean

Fields
Methods

Character

Fields

Class

Methods

ClassLoader

Compiler

Methods

Double extends Number

Fields
Methods

Float extends Number

Fields
Fields

Integer extends Number

Fields
Methods

Long extends Number

Fields
Methods

Math

Fields
Methods

abstract Number

Methods

Object

Methods

Process

Methods

Runtime

Methods

abstract SecurityManager

Fields
Methods

String

Methods

StringBuffer

Methods

System

Fields
Methods

Thread implements Runnable

Fields
Methods

ThreadGroup

Throwable

Methods

Interfaces

Cloneable

Runnable

Methods

java.net

Inasmuch as Java is a networked-based language, this comparatively small package is very useful. Most importantly, it provides you with the ability to communicate with other sources of information - by creating or connecting to sockets or making use of URLs.

Classes

abstract ContentHandler

Methods

DatagramPacket

Methods

DatagramSocket

Methods

final InetAddress

Methods

ServerSocket

Methods

Socket

Methods

abstract SocketImpl

Fields
Methods

URL

abstract URLConnection

Fields
Methods

URLEncoder

Methods

abstract URLStreamHandler

Methods

Interfaces

ContentHandlerFactory

Methods

SocketImplFactory

URLStreamHandlerFactory

Methods

java.util

This package is esentially a smorgasbord of useful classes that did not truly fit in any of the other packages. Among these handy classes are the Date class, designed to manage and handle operations with dates; the Hashtable class; and classes to develop ADTs such as Stack and Vector.

Classes

BitSet implements java.lang.Cloneable

Methods

Date

Methods

abstract Dictionary

Hashtable extends Dictionary implements java.lang.Cloneable

Observable

Properties extends Hashtable

Fields
Methods

Random

Stack extends Vector

StringTokenizer implements Enumeration

Vector implements java.lang.Cloneable

Fields
Methods

Interfaces

Enumeration

Methods

Observer

sun.tools.debug

The sun.tools.debug package is designed to provide for remote debugging with the Java Debugger (JDB). Examining these classes will provide you with some understand of this process. While normal code will have no need to make use of this package, this package provides you with the ground-work on which you may build a more useful and user-friendly debugger - something the Sun openly encourages.

Classes

RemoteArray extends RemoteObject

Methods

RemoteBoolean extends RemoteValue

Methods

RemoteByte extends RemoteValue

Methods

RemoteChar extends RemoteValue

Methods

RemoteClass extends RemoteObject

Methods

RemoteDebugger

Methods

RemoteDouble extends RemoteValue

Methods

RemoteField extends Field

Methods

RemoteFloat extends RemoteValue

Methods

RemoteInt extends RemoteValue

Methods

RemoteLong extends RemoteValue

Methods

RemoteObject extends RemoteValue

Methods

RemoteShort extends RemoteValue

Methods

RemoteStackFrame extends StackFrame

Methods

RemoteStackVariable extends LocalVariable

Methods

RemoteString extends RemoteObject

Methods

RemoteThread extends RemoteObject

Methods

RemoteThreadGroup extends RemoteObject

Methods

RemoteValue

Methods

StackFrame

Methods

LocalVariable

The sun.tools.debug.LocalVariable class is not a public class, but rather one restricted for use only within the sun.tools.debug package. This is due to the fact that the class itself and all its fields are defined with the "friendly" (no access modifiers specified). Although it is not meant for use by the Java developer, it is nevertheless listed here due to the dependence on this class by other classes in the package.

Fields

Interface

DebuggerCallback

Exceptions

Exceptions provide you with a means of managing the ordinary run-time problems that may be encountered during execution of your program. Exceptions are thrown by methods and are handled with try-catch blocks.

All exceptions are derived from the java.lang.Exception class and most consist only of two constructor methods. Consequently, only the constructor methods for the java.lang.Exception class are listed here. Unless otherwise noted, all exceptions may be created with no paramters or with a descriptive string as a paramter.

java.awt

AWTException

java.io

EOFException extends IOException

FileNotFoundException extends IOException

IOException extends java.lang.Exception

InterruptedIOException extends IOException

UTFDataFormatException extends IOException

java.lang

ArithmeticException extends RuntimeException

ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException

Constructors

ArrayStoreException extends RuntimeException

ClassCastException extends RuntimeException

ClassNotFoundException extends Exception

CloneNotSupportedException extends Exception

Exception extends Throwable

Methods

IllegalAccessException extends Exception

IllegalArgumentException extends RuntimeException

IllegalMonitorStateException extends RuntimeException

IllegalThreadStateException extends RuntimeException

IndexOutOfBoundsException extends RuntimeException

InstantiationException extends Exception

InterruptedException extends Exception

NegativeArraySizeException extends RuntimeException

NoSuchMethodException extends Exception

NullPointerException extends RuntimeException

NumberFormatException extends IllegalArgumentException

RuntimeException extends Exception

SecurityException extends RuntimeException

StringIndexOutOfBoundsException extends IndexOutOfBoundsException

Constructors

java.net

MalformedURLException extends java.lang.IOException

ProtocolException extends java.lang.IOException

SocketException extends java.lang.IOException

UnknownHostException extends java.lang.IOException

UnknownServiceException extends java.lang.IOException

java.util

EmptyStackException extends java.lang.RuntimeException

Constructors

NoSuchElementException extends java.lang.RuntimeException

Errors

While errors and exceptions are both based on the java.lang.Throwable class, errors are designed to manage more critical run-time errors. Errors may be handled in a similar manner to exceptions, but unless you clearly understand the problem and have devised a suitable way of resolving it, error-handling is not something that should be used in your code.

Similar to exceptions, all errors are derived from java.lang.Error. Most errors contain only constructor methods and most contain only two ErrorName() and ErrorName(String message). While all errors are listed here, only those errors whose constructors do not conform to the principle are listed here.

java.awt

AWTError extends java.lang.Error

Constructors

java.lang

AbstractMethodError extends IncompatibleClassChangeError

ClassCircularityError extends LinkageError

ClassFormatError extends LinkageError

Error extends Throwable

Methods

IllegalAccessError extends IncompatibleClassChangeError

IncompatibleClassChangeError extends LinkageError

InstantiationError extends IncompatibleClassChangeError

InternalError extends VirtualMachineError

LinkageError extends Error

NoClassDefFoundError extends LinkageError

NoSuchFieldError extends IncompatibleClassChangeError

NoSuchMethodError extends IncompatibleClassChangeError

OutOfMemoryError extends VirtualMachineError

StackOverflowError extends VirtualMachineError

ThreadDeath extends Error

Constructors

UnknownError extends VirtualMachineError

UnsatisfiedLinkError extends LinkageError

VerifyError extends LinkageError

VirtualMachineError extends Error

QUE Home Page

For technical support for our books and software contact support@mcp.com

Copyright ©1996, Que Corporation