Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default SAX Parser in Java 8

Tags:

java-8

sax

I'm struggling to put some order in my mind about SAX/DOM integration with Java. I find the information over the Internet messy. I would appreciate if someone could answer some, probably knives, simple questions. Here's my environment:

  • Eclipse Oxygen.
  • Java 8.
  • Maven Project without any dependencies (is a simple console test project).

My Questions

  • What parsers (SAX/DOM) come packaged, if any, with Java 8? I couldn't find information over the Internet.
  • After deleting CLASSPATH from my environment, ensure no org.xml.sax.driver system property was set, XMLReaderFactory.createXMLReader() method still returns an object com.sun.org.apache.xerces.internal.parsers.SAXParser. Where does it come from?
like image 556
Jacinto Resende Avatar asked Feb 28 '26 06:02

Jacinto Resende


1 Answers

The version of the (default) Xerces parsers you have in your JVM depends on the Java build you are using. As you can see from https://bugs.openjdk.org/browse/JDK-8282280, the OpenJDK team will (if necessary) pull in an updated Xerces version into the OpenJDK code tree ... and backport the change to supported versions of Java.

There is an article in the Oracle Knowledgebase on how find out what a JVM's Xerces version is, but you need an Oracle Support account to read it:

  • How to Determine the Version of Xerces Built into a Java Runtime Environment (Doc ID 1480885.1)

Apparently on Java 8 you can find this out by running:

$ java com.sun.org.apache.xerces.internal.impl.Version

... but this doesn't work in later versions. (Perhaps, someone can comment to supply the new recipe?)


This Q&A is also relevant, but I don't think it answers the "what version" question for a JVM's builtin Xerces implementation:

  • How do I find out which JAXP implementation is in use and where it was loaded from?
like image 63
Stephen C Avatar answered Mar 04 '26 12:03

Stephen C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!