Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

The JAXP and Reference Implementation JAR Files

The Java Web Services Developer Pack (JWSDP) provides six JAR files for supporting JAXP and its reference implementation. These are listed in Table 3.6.

Table 3.6 The JAXP and Reference Implementation JAR Files

JAR Files

Functions

jaxp-api.jar

This JAR file contains the javax.xml.parsers and javax.xml.transform components of JAXP.

sax.jar

This JAR file contains the SAX APIs and the helper classes.

dom.jar

This JAR file contains the DOM APIs and the helper classes.

XercesImpl.jar

This JAR file contains the implementation classes for the SAX and DOM parsers.

xalan.jar

This JAR file contains the implementation of the Xalan XSLT processor.

xsltc.jar

This JAR file contains the implementation of the Xalan XSLTC XSLT processor.


All the JAR files, with the exception of jaxp-api.jar, are located in the <jwsdp_home>\common\endorsed location. The jaxp-api.jar file is located in the <jwsdp_home>\common\lib location.

Setting Up JAXP and the JAXP Reference Implementation

After you have downloaded the JWSDP and run the installer, you need to set up the JAXP and JAXP reference implementation JAR files so the Java compiler can find the necessary library files when compiling your application. Setting up the JAR files depends on the version of JDK being used.

Java 1.2 or Java 1.3

If you are using Java 1.2 or 1.3, you can make the JAR files available in one of the following two ways:

  • To make the JAR files available as standard extensions, place all the JAR files in the <install_dir>/jre/lib/ext location.

  • To make the JAR files available through the classpath mechanism, you can either add the JAR files to the classpath environment variable, or use the -classpath option.

CAUTION

You should follow only one of the two mechanisms as suggested here, not a mixture of both. This is because the way the compiler works is that only the referenced classes are loaded from the ext directory, and classpath settings are not considered when calculating references. But when the classpath is searched, the ext directory is not searched because all ext classes are expected to have been loaded. Therefore, splitting the JAR files between the two locations can create a situation where a class referenced on the classpath has not been loaded from the ext directory, after which it cannot be found. This will lead to compilation errors.

Java 1.4

As of this version, Xalan libraries are part of the standard Java 1.4 platform. However, because the Xalan libraries are developed and released independent of Java versions, newer versions of the libraries may be available for use before newer versions of Java are released. In fact, the Xalan libraries that are part of the JWSDP download pack are newer than the ones that are included with the Java 1.4 platform. Naturally, you would want to use the latest libraries while compiling and running your application.

Because the Xalan libraries are part of the core JVM, using the –classpath option to indicate the path of the newer libraries will not work. This is because if a library is available in the core JVM, the compiler will always use it and ignore the settings specified in the –classpath option. To overcome this problem, Java 1.4 provides the Endorsed Standards Override Mechanism, which lets you override the core libraries of the Java 1.4 platform. To do so, you need to place the updated libraries in the <install_dir>/jre/lib/endorsed location.

Therefore, for the Java 1.4 version, place all the JAR files except jaxp-api.jar in the <install_dir>/jre/lib/endorsed location.

The jaxp-api.jar file need not be put into the endorsed location, because it is released by Sun and is not an endorsed standard. This file can stay where it is: in the <jwsdp>/common/lib location.

There is another way by which you can ensure that the newer JAR files are added to the JVM dynamically when you execute the application. This is achieved by setting the appropriate values in the java.endorsed.dirs system property. Setting this property ensures that specified JAR files will be searched before the core classes of the JVM. However, you need to remember that there is no fixed order in which the JAR files will be searched. Therefore, you need to ensure that when using this property, there are no overlaps of classes defined in the JAR files.

  • + Share This
  • 🔖 Save To Your Account