'; zhtm += ''; zhtm += '

' + pPage + ''; zhtm += '
'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 } //--> Java 1.2 Unleashed -- Appendix E -- The Java Extensions Framework

Java 1.2 Unleashed

Previous chapterNext chapterContents

- E -

The Java Extensions Framework

The Java Extensions Framework allows the Core API to be extended with user- developed packages. This capability is useful in a number of scenarios. For example, if your organization maintains an intranet that uses Java applets and applications, it may be useful to install organization-specific packages (especially those that use native code) as standard extensions. In this way, these packages are available to all users and needed classes and interfaces are treated as extensions to the Core API.

In another scenario, consider a set of consumer-oriented, Web-based applets. Suppose these applets all use a set of common packages. You can create a downloaded extension that is referenced in the applets' JAR files. This frees you from having to package the common classes in each applet's JAR file.

JDK 1.2 supports two types of extension: installed extensions and downloaded extensions. As you might have guessed, installed extensions are installed in the local classpath, and downloaded extensions are downloaded from URLs. Both installed and downloaded extensions are packaged as JAR files.

Installed Extensions

Installed extensions consist of JAR files that are placed in a particular location within the local file system. These JAR files are installed in the /lib/ext subdirectory of the JAVA_HOME directory. Refer to Appendix B, "Java Environment Variables," for a definition of the JAVA_HOME environment variable. On Windows-based systems, native code is installed in the /bin subdirectory of the JAVA_HOME directory. When the Java virtual machine looks for a class, it first searches its list of system classes. After that, it searches the /lib/ext directory. If the class is still not found, it searches through the downloaded extension classes, and finally, throughout other directories in the CLASSPATH.

Installed extensions are particularly useful when a number of packages that use native code must be distributed throughout an organization.

Downloaded Extensions

Downloaded extensions consist of JAR files that are referenced in the JAR files of applets and applications. The extension's JAR file is referenced in the manifest of the applet's JAR file. This reference occurs in the Class-Path header field. For example, consider the following header field:

Class-Path: MyExtensions.jar YourExtensions.jar TheirExtensions.jar

This references three extension JAR files. The URLs of these files are relative to the applet's URL. Consult Chapter 8, "Applet Security," for information on how to specify the header fields in the manifest of a JAR file. Extension files are subject to the Java security policy. If extensions are referenced by applets, it is a good idea to sign the extensions.

NOTE: Installed extensions may contain native code, but downloaded extensions may not.

Previous chapterNext chapterContents

© Copyright, Macmillan Computer Publishing. All rights reserved.