开发者

How to use jaxp 3 with jdk 1.6?

开发者 https://www.devze.com 2022-12-30 08:21 出处:网络
I\'m trying to migrate application from jdk 1.5 to jdk 1.6 without introducing any changes visible to the end user.

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 i开发者_高级运维s 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号