I have recently switched an application from Java 1.4 to Java 6. I am having problems with one bit that parses XML using SAX.
The old code did this: -
Under Java 6, this causes a ClassNotFoundException (not at the above code, but when it tries to parse XML).
Under Java 6, if we simply don't bother with this code at all, it seems to parse XML just fine. So, in a way, I already have a solution. But I would like to know exactly what's changed in the Java distributions and why.
A quick Google didn't reveal the answers I'd hoped for. Can anyone point me to appropriate documentation about what XML SAX parser(s) are in what JDK?
It's been a while since I have worked with XML on Java 1.4. Are you really sure that you have to set this system property (org.xml.sax.driver)? What happens if you just don't set that system property? I'd expect that it should work also on Java 1.4 without setting that property.
[ April 24, 2007: Message edited by: Jesper Young ]
I can say that it appears to work in Java 6 without any code to specify any particular SAX parser.
What I am likely to do is to conditionalise the system property setting code so that it only runs if Java version is 1.4 (Mac OS X still on 1.4 in our app). We'll then have to re-do lots of testing, to make sure everything is OK with the SAX parser that's in Java 6.
FTR I eventually found this Sun document, which explains the stuff I needed to know.
java -Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl ...
Looking at just the Java version might not be enough. What if someone is running your program with IBM JVM version 1.4? It might use something else than Crimson.
Anyway, for the future running Java 6, I intend not to specify a specific version. For compatibility with the past Java 1.4, I intend to continue specifying what we always specified.
We could do a test by trying to load the specified class at the time of setting the system property.
[ April 24, 2007: Message edited by: Peter Chase ]
Originally posted by Rahul Bhattacharjee:
I am wondering why it isn't backward compatible.
It's not backwards compatible because our code specifically requests the Crimson parser, which is missing in Java 6 (and 5, I think).
As discussed above, the norm is not to specify a particular parser, but to let Java choose.
Originally posted by Peter Chase:
We distribute the JRE with our application, so it runs on what we choose. Except on Mac OS X, where it runs on what Apple give you. Either way, there is little/no chance of suddenly encountering an unexpected Java version.
Well I could just as well have written "Apple's Java" instead of "IBM Java" - Apple's implementation isn't the same as Sun's, so there's no guarantee that Crimson will be present in Apple's Java.