Extensions - An Overview |
lib/classes.zip
in the JDK or in lib/rt.jar
in the JRE.) The extension mechanism also provides a way for
needed extensions to be retrieved from specified URLs when they are not
already installed in the JDK or JRE.
Extensions are embodied in JAR files. Every JAR file is a potential extension. A JAR file can be made to play the role of an extension in two ways:
where<java-home>/lib/ext
<java-home>
is the top-level directoy
of the JDK or JRE. Classes within JAR files in
this directory can be used by applets and applications much as if they were
part of the set of system classes, without having to explicitly
include them in the classpath.
An installed extension's native code binaries, if any, are placed in
where<java-home>\bin [Win32] <java-home>/lib/<arch> [Solaris]
<arch>
is the Solaris processor architecture,
either sparc
or x86
.
When the Java VM
encounters a class name, it looks first for the class in the set
of system classes. If it fails to find the desired class among
the system classes, the VM will then search for the class in any JAR files
in <java-home>/lib/ext
.
Note that there is nothing special about any particular JAR file
itself or the classes it contains that makes it an installed extension.
It is an installed extension by virtue of its location in
<java-home>/lib/ext
.
If a class is not found after searching both the system classes and the classes in the installed extensions, the extension mechanism will search for the class in a download extension....
Download extensions are specified in the "Class-Path" header field in the manifest file of an applet, application, or another extension. A Class-Path header might look like this, for example:
With this header field, the classes in the filesClass-Path: servlet.jar infobus.jar acme/beans.jar
servlet.jar
,
infobus.jar
, and acme/beans.jar
will serve
as extensions for purposes of the applet or application. The URLs
in the Class-Path field are given relative to the URL of the
JAR file of the applet or application.
Unlike the case of installed extensions, the location of the JAR files that serve as download extensions is irrelevent. A download extension is an extension because it is referenced from the Class-Path header in another JAR file's manifest, not because it has any particular location.
Another difference between installed and download extensions is that only applets and applications bundled in a JAR file can make use of download extensions. Applets and applications not bundled in a JAR file don't have a manifest from which to reference download extensions.
When searching for a class, the VM first searches among the classes in the system classes and in any installed extensions. If the class is not found in either the system classes or in the installed extensions, the VM will search for the class in any download extensions referenced by the manifest of the application or applet. A download extension will not be downloaded if a desired class is found among the installed extensions, even if the download extension is referenced by the manifest file of the applet or application.
The extension mechanism will not install a download extension in the JRE or JDK directory structure. Download extensions do not become installed extentions after they have once been downloaded.
Unlike installed extensions, download extensions cannot have any native code.
Copyright © 1997
Sun Microsystems, Inc.
All Rights Reserved.
Please send comments to: Java Software |
Java Software |