由于对所需库 rt.jar 的限制而导致对类的访问限制? [英] Access restriction on class due to restriction on required library rt.jar?

查看:31
本文介绍了由于对所需库 rt.jar 的限制而导致对类的访问限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Java5 上编译由 IBM WSDL2Java 创建的 Java 1.4 代码,而无需重新创建存根并在 Eclipse 中看到此错误.
我假设只要运行时 jars 可用(它们可用),生成的存根就应该编译.

I'm attempting to compile Java 1.4 code that was created by IBM's WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse.
I'm under the assumption that the stubs generated should just compile as long as the runtime jars are available (they are).

访问限制:由于所需库 C:\Program Files\Java\jdk1.5.0_16\jre\lib\rt.jar 的限制,类型 QName 不可访问

完整的类名是javax.xml.namespace.QName

这里到底发生了什么?这是我试图从香肠重构猪的情况吗?我最好重新创建存根吗?

What exactly is going on here? Is this a case where I am trying to refactor a pig from sausage? Am I better off recreating the stubs?

推荐答案

还有另一种解决方案也有效.

There's another solution that also works.

  1. 转到项目属性中的构建路径设置.
  2. 删除JRE 系统库
  3. 把它加回来;选择添加库",然后选择JRE 系统库.默认设置对我有用.
  1. Go to the Build Path settings in the project properties.
  2. Remove the JRE System Library
  3. Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.

这是有效的,因为您在不同的 jar 文件中有多个类.删除并重新添加 JRE 库将使正确的类成为第一位.如果您想要一个基本的解决方案,请确保排除具有相同类的 jar 文件.

This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first. If you want a fundamental solution make sure you exclude the jar files with the same classes.

对我来说,我有:javax.xml.soap.SOAPPart 在三个不同的 jar 中:axis-saaj-1.4.jarsaaj-api-1.3.jarrt.jar

For me I have: javax.xml.soap.SOAPPart in three different jars: axis-saaj-1.4.jar, saaj-api-1.3.jar and the rt.jar

这篇关于由于对所需库 rt.jar 的限制而导致对类的访问限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆