简体   繁体   中英

How to use jaxp 3 with jdk 1.6?

I'm trying to migrate application from jdk 1.5 to jdk 1.6 without introducing any changes visible to the end user. Application's output is an xml generated using jaxp which is a part of the jdk libraries. Since jaxp versions are different in jdk 1.5 and 1.6, the resulting xml looks different in each version.

An example: DatatypeFatory.newInstance().newDuration(60) produces 'PT2H17M0.000S' in jdk 1.5 and 'P0Y0M0DT2H17M0.000S' in jdk 1.6. Both are correct, but i want to avoid any visible changes.

Classes like DatatypeFactory have a mechanism which allows specifying which implementation should be used, but it relies on specifying full qualified class name. So theoretically i could download jaxp jars with the same version which is used in jdk 1.5 and let the application use them. Unfortunately the package and class names are the same in both versions, so i would have to somehow tell java to load classes from jar and not jdk. I was trying to put jaxp jars at the beginning of the classpath, but it didn't help.

Is it possible to tell java to load classes from external jar and not jdk libraries? Can i solve this problem in any other way?

Thanks in advance

Unfortunately the package and class names are the same in both versions, so i would have to somehow tell java to load classes from jar and not jdk.

it is all decide by classLoader. 1. you can't except the jdk lib. 2. your third jar has the same name and class name.

other thing you can do,rewrite with the third jar's packageName,and recompile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM