Groups of related classes bundled into a package. Packages can also contain interface definitions.
package graphics; interface Draggable { . . . } class Circle { . . . } class Rectangle { . . . }
The .class files generated must be placed in a directory named graphics somewhere in your CLASSPATH.
CLASSPATH: A list of directories that indicate where on the file system you've installed various compiled Java classes and interfaces.
Java searches your CLASSPATH for a directory whose name matches the package name of which the class is a member.
Note: If you don't specify a package, your classes and interfaces become members of the default package, which has no name.
To use the classes and interfaces defined in one package from within another package, you need to import the package:
import graphics.Circle; import graphics.*;
Also, the classes and interfaces must be declared public.
This packages are always automatically imported:
The default package (a package with no name);
The java.lang package.
It contains classes that are core to the Java language:
Object: The class from which all others inherit.
Data Type Wrappers: A collection of classes used to wrap variables of a primitive data type.
Strings: Two classes that implement character data.
System and Runtime : These two classes provide let your programs use system resources.
Threads: It implements the multi-threading capabilities so important to the Java language.
Classes: The Class class provides a runtime description of a class and the ClassLoader class allows you to load classes during runtime.
Math: A library of math routines and values such as pi.
Exceptions, Errors and Throwable: Classes that handle errors.
Processes: Process objects represent the system processes.
This Java package, java.util, contains a collection of utility classes.
This package contains the Applet class -- the class that you must subclass if you're writing an applet.
Three packages comprise the Abstract Window Toolkit.
Copyright © 1998-2009 Dilvan Moreira