Java Using Extensions or Other Packaged APIs
Problem
You have a JAR file of classes you want to use.
Solution
Simply copy the JAR into JDKHOME/jre/lib/ext/.
Explained
The Java API has grown by leaps and bounds since its first public release in 1995. It
is now considered sufficiently functional for writing robust applications, but the
areas to which it is being applied continue to grow. Some specialized APIs may
require more resources than you have on a given Java platform. Many of the new APIs from Sun are in the form of standard extensions, which is indicated by their
package names beginning in javax.. Classes in packages named java. or javax. are
treated as built-in classes by a web browser for purposes of applet security, for example.
Each extension is distributed in the form of a JAR file (see Recipe 23.4).
If you have a Java runtime that does not support this feature, you may need to add
each JAR file to your CLASSPATH, as in Recipe 1.4.
As you accumulate these and other optional APIs contained in JAR files, you can
simply drop these JAR files into the Java Extensions Mechanism directory, typically
something like \jdk1.4\jre\lib\ext., instead of listing each JAR file in your CLASSPATH
variable and watching CLASSPATH grow and grow and grow. The runtime
looks here for any and all JAR and zip files, so no special action is needed. In fact,
unlike many other system changes, you do not even need to reboot your computer;
this directory is scanned each time the JVM starts up. You may, however, need to
restart a long-running program such as an IDE for it to notice the change. Try it and
see first.
No comments:
Post a Comment