JDK 1.6 and Xerces?

Bundling an XML parser has not been necessary since 1.4 when JAXP was added to the JRE. You should use JAXP and not directly call Xerces. Internally, the JRE bundles and uses Xerces anyways (with a "com.sun" prefix).


These XML services plug in application environment using so-called "service provider" mechanism.

It works as follows:

  1. It tries to find system property that exactly points to factory class, that should be used. E.g. -Djavax.xml.parsers.SAXParserFactory=<some class>.
  2. If system property was not found FactoryFinder looks for property in special properties file. For example ${java.home}/lib/jaxp.properties.
  3. If file property was not found FactoryFinder looks for service description in class path META-INF/services/<some service>, e.g. META-INF/services/javax.xml.parsers.SAXParserFactory. It is a file that should contain factory class name for example org.apache.xerces.jaxp.SAXParserFactoryImpl.
  4. If there are no such files in class path java uses its default factory implementation.

So if you do not have system property pointing to evident factory class java will choose suitable implementation quietly.

Tags:

Java

Xml

Legacy