Previous | Next | Trail Map | The Java Development Environment | Managing Your Programming Environment


Using Objects and Classes from Other Packages

To import a specific object in a package, like Applet in the java.applet package, use the import statement.
import java.applet.Applet;
To import all objects in a package, for example, the entire java.applet package, use the import statement with the '*' wildcard character.
import java.applet.*;
Importing an object, or an entire package of objects makes the definitions and implementations available to the current package. For example, suppose that you're writing a small Applet:
class MyApplet extends Applet {
    . . .
}
If you try to compile this applet without importing the java.applet.Applet class, the compiler will issue this fatal error:
MyApplet.java:2: Super class Applet of class MyApplet not found.


Previous | Next | Trail Map | The Java Development Environment | Managing Your Programming Environment