JDK 1.6 and Xerces?

Glenn Bech picture Glenn Bech · Oct 17, 2011 · Viewed 22.3k times · Source

In my current project, we target a JDK 1.6 Runtime environment. For legacy rasons, Xerces JAR files are bundled in the application.

These are no longer needed right? The JDK has (for a while) had XML parsing libraries bundled in the JDK?

Answer

svaor picture svaor · Oct 17, 2011

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.