打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Using JAXB 2.1 with JavaSE 6
userphoto

2009.03.31

关注
 
JavaSE 6 comes with JAXB 2.0 API in rt.jar . Therefore, using JAXB 2.1 with JavaSE 6 requires one to override a portion of rt.jar with the new API. There are several ways to do this:
  1. Place the 2.1 jaxb-api.jar into $JRE_HOME/lib/endorsed . This essentially makes your JRE to "JRE 6 + JAXB 2.1". This won't affect any other applications that use this JRE, and it's easy. On the other hand, in various scenarios you may not be able to alter the JRE.
  2. Use the system property java.endorsed.dirs when you launch your application, and have it point to the directory that contains the 2.1 jaxb-api.jar . This allows you use use JAXB 2.1 without modifying the JRE. Make sure not to include any other JAXB RI jar files (such as jsr173-api.jar or jaxb-impl.jar .)
  3. Implement a custom ClassLoader and block delegation to javax.xml.bind package, so that code running inside this class loader will load the JAXB API from elsewhere. This is a very advanced approach.
No matter which approach you take, make sure not to include jar files other than jaxb-api.jar . Doing so, for example including jaxb-xjc.jar , may result in classloading related errors such as "taskdef A class needed by class com.sun.tools.xjc.XJCTask cannot be found: org/apache/tools/ant/...."
See the endorsed directory mechanism for more details.

jdk6update12也可解决
 

https://jaxb.dev.java.net/guide/Which_JAXB_RI_is_included_in_which_JDK_.html
Which JAXB RI is included in which JDK?

This table captures the history of the JAXB RI integration into Java6. This is for information purposes only. In particular, the JAXB RI in JDK6 is package renamed to avoid any conflict with the stand-alone JAXB RI distribution or with the jaxb2-reflection library. You can use any version of these with any version of JDK without worrying about implementation conflicts.

JDK6 first release - JDK6 u3 JAXB RI 2.0.3
JDK6 u4 JAXB RI 2.1.3

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Java 8新特性探究(八)精简的JRE详解
解决javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
windows系统下JDK1.6环境变量配置
java第一天
如何在MyEclipse中添加javadoc文档
解决myeclipse5.1GA上的破烂事
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服