Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

java - 由于对所需库rt.jar的限制而导致对类的访问限制?(Access restriction on class due to restriction on required library rt.jar?)

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.

(我试图在不重新创建存根的情况下编译由IBM的WSDL2Java在Java5上创建的Java 1.4代码,并在Eclipse中看到此错误。)

I'm under the assumption that the stubs generated should just compile as long as the runtime jars are available (they are).

(我的假设是,只要运行时jar可用(它们存在),生成的存根就应该编译。)

Access restriction: The type QName is not accessible due to restriction on required library C:\Program Files\Java\jdk1.5.0_16\jre\lib\rt.jar

The full class name is javax.xml.namespace.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?

(我最好重新创建存根吗?)

  ask by sal translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There's another solution that also works.

(还有另一个解决方案也可以。)

  1. Go to the Build Path settings in the project properties.

    (转到项目属性中的“ 构建路径”设置。)

  2. Remove the JRE System Library

    (删除JRE系统库)

  3. Add it back;

    (加回去;)

    Select "Add Library" and select the JRE System Library .

    (选择“添加库”,然后选择JRE系统库 。)

    The default worked for me.

    (默认为我工作。)

This works because you have multiple classes in different jar files.

(之所以可行,是因为您在不同的jar文件中有多个类。)

Removing and re-adding the JRE lib will make the right classes be first.

(删除并重新添加JRE库将使正确的类成为第一位。)

If you want a fundamental solution make sure you exclude the jar files with the same classes.

(如果需要基本解决方案,请确保排除具有相同类的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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...