13.12.  JAXP-Configuration

The standard configuration of JAXP can be changed in several ways. Because they are not all well known, they will be explained in the following sections using Xerces and Xalan.

The Java runtime reads the following environment variables and tries to load their values as classes:


These properties can be set in different ways, which are shown by the following numbered sections. If a configuration option can override another, the one with the higher is described first.

  1. The JAXP properties can be set directly in a program:

  2. A configuration parameter for the Java process to be started can be set using the flag for system properties -D in combination with the special environment variable _JAVA_OPTIONS. The next example shows one of the three JAXP properties, but of course all three are possible:

    set _JAVA_OPTIONS=-Djavax.xml.transform.TransformerFactory=
  3. The configuration with the start option -D can also be placed in the special environment variable JAVA_TOOL_OPTIONS. This variable is evaluated by some JDK implementations. The next example shows this option again with only one property:

    set JAVA_TOOL_OPTIONS=-Djavax.xml.transform.TransformerFactory=
  4. The JAXP configuration can also be placed in the file jaxp.properties in the folder JAVA_HOME/jre/lib:

    # Sample configuration, file %JAVA_HOME%\jre\lib\jaxp.properties.
    # Defaults in Java 1.7.0, Windows:
    #javax.xml.parsers.DocumentBuilderFactory = \
    #javax.xml.parsers.SAXParserFactory       = \
    #javax.xml.transform.TransformerFactory   = \
    # Values for Xerces and Xalan:
    javax.xml.parsers.DocumentBuilderFactory = \
    javax.xml.parsers.SAXParserFactory       = \
    javax.xml.transform.TransformerFactory   = \
  5. And a special technique for ANT is to use the environment variable ANT_OPTS:

    set ANT_OPTS=-Djavax.xml.transform.TransformerFactory=
    set ANT_OPTS=-Djavax.xml.parsers.DocumentBuilderFactory=
    set ANT_OPTS=-Djavax.xml.parsers.SAXParserFactory=

The declared XML and XSLT classes have to be found in the classpath or in the folder JAVA_HOME\jre\lib\ext. This last option is not recommended because only a few developers know about it. In case you are debugging a strange problem, you would not think to look at the version of the JAR's in that folder.

Note that Eclipse reads all existing environment variables only at startup and does not change anything later.