Programing

필수 라이브러리 rt.jar에 대한 제한으로 인해 클래스에 대한 액세스 제한이 있습니까?

lottogame 2020. 9. 29. 07:11
반응형

필수 라이브러리 rt.jar에 대한 제한으로 인해 클래스에 대한 액세스 제한이 있습니까?


스텁을 다시 만들지 않고 IBM의 WSDL2Java에서 Java5로 만든 Java 1.4 코드를 컴파일하려고 시도 중이며 Eclipse에서이 오류를 확인했습니다. 생성 된 스텁은 런타임 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

전체 클래스 이름은 javax.xml.namespace.QName

여기서 정확히 무슨 일이 일어나고 있습니까? 소시지에서 돼지를 리팩토링하려는 경우입니까? 스텁을 다시 만드는 것이 더 낫습니까?


작동하는 또 다른 솔루션이 있습니다.

  1. 프로젝트 속성에서 빌드 경로 설정으로 이동 합니다.
  2. JRE 시스템 라이브러리 제거
  3. 다시 추가하십시오. 선택 "라이브러리 추가" 와 선택 JRE 시스템 라이브러리를 . 기본값은 나를 위해 일했습니다.

이것은 다른 jar 파일에 여러 클래스가 있기 때문에 작동합니다. JRE lib를 제거하고 다시 추가하면 올바른 클래스가 첫 번째가됩니다. 기본 솔루션을 원한다면 동일한 클래스를 가진 jar 파일을 제외해야합니다.

: 나를 위해 내가 가진 javax.xml.soap.SOAPPart세 가지 다른 항아리에 : axis-saaj-1.4.jar, saaj-api-1.3.jar그리고rt.jar


http://www.digizol.com/2008/09/eclipse-access-restriction-on-library.html이 가장 잘 작동했습니다.

Windows : Windows-> 환경 설정-> Java-> 컴파일러-> 오류 / 경고-> 더 이상 사용되지 않고 제한된 API-> 금지 된 참조 (액세스 규칙) :-> 경고로 변경

Mac OS X / Linux : Eclipse-> 환경 설정-> Java-> 컴파일러-> 오류 / 경고-> 더 이상 사용되지 않고 제한된 API-> 금지 된 참조 (액세스 규칙) :-> 경고로 변경


나는 같은 문제를 만났다. http://www.17ext.com 웹 사이트에서 답을 찾았습니다 .
먼저 JRE 시스템 라이브러리를 삭제합니다. 그런 다음 JRE 시스템 라이브러리를 다시 가져옵니다.

이유를 모르겠지만 문제가 해결되었으므로 도움이 되었으면합니다.


내 생각에 Java 5와 함께 제공되는 표준 클래스를 라이브러리의 클래스로 바꾸려고합니다.

이것은 라이센스 계약 조건에 따라 허용되지 않지만 AFAIK는 Java 5까지 시행되지 않았습니다.

나는 이전에 QName으로 이것을 보았고 내가 가지고 있던 병에서 클래스를 제거함으로써 그것을 "고쳤다".

"-Xbootclasspath :"옵션에 대한 http://www.manpagez.com/man/1/java/ 메모를 편집 하십시오 .

"rt.jar에서 클래스를 재정의 할 목적으로이 옵션을 사용하는 응용 프로그램은 배포하면 안됩니다. 그렇게하면 Java 2 Runtime Environment 바이너리 코드 라이센스에 위배됩니다."

http://www.idt.mdh.se/rc/sumo/aJile/Uppackat/jre/LICENSE

"Java 기술 제한 사항."Java "패키지 또는"java "패키지의 하위 패키지에 포함 된 클래스로 식별되는 Java 플랫폼 인터페이스 ("JPI ")를 JPI 내에 추가 클래스를 만들거나 JPI의 클래스 추가 또는 수정. (i) Java 플랫폼의 기능을 확장하고 (ii) 타사 소프트웨어 개발자에게 노출되는 추가 클래스 및 관련 API를 생성하는 경우 이러한 추가 API를 호출하는 추가 소프트웨어를 개발할 목적으로 모든 개발자가 무료로 사용할 수 있도록 해당 API에 대한 정확한 사양을 즉시 게시해야합니다. 추가 클래스, 인터페이스를 만들거나 라이선스 사용자에게 권한을 부여 할 수 없습니다.또는 어떤 방식 으로든 "java", "javax", "sun"또는 Sun이 명명 규칙 지정에서 지정한 유사한 규칙으로 식별되는 하위 패키지. "


이 오류도 발생했지만 내 프로젝트는 Maven과 tycho 컴파일러 (OSGi 플러그인 세트)를 사용하여 명령 줄에서 빌드되었습니다 . 같은 문제를 가지고 있지만 명령 줄이 아닌 Eclipse에서 수정 한 사람들을 대량으로 살펴본 후 Tycho 개발자 포럼pom.xml 에서 액세스 제한에 대한 컴파일러 경고를 무시하기 위해 구성을 사용하여 내 질문에 답한 메시지를 발견 했습니다 .

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-compiler-plugin</artifactId>
    <version>${tycho.version}</version>
    <configuration>
        <compilerArgument>-warn:+discouraged,forbidden</compilerArgument>
    </configuration>
</plugin>

자세한 내용은 Tycho FAQ 에서 찾을 수 있습니다 . 이로 인해 AGES가 해결 되었으므로이 답변을 게시하여 명령 줄에서 이러한 액세스 제한 오류를 수정하려는 다른 사람을 도울 것이라고 생각했습니다.


  • 프로젝트 속성에서 빌드 경로 설정으로 이동합니다. Windows -> Preferences -> Java Compiler
  • JRE 시스템 라이브러리 제거
  • Add another JRE with a "perfect match"
  • clean and build your project again. It worked for me.

I just had this problem too. Apparently I had set the JRE to 1.5 instead of 1.6 in my build path.


In addition to Nels Beckman's solution, I have the following tips:

Under Configure Build Path, I had to rearrange the order of my entries under Order and Export.

Additionally, as an Eclipse PDE developer, I needed to rearrange the order of my dependencies in my MANIFEST.MF, adding the problematic package as first on the list.

Playing with these dials, along with running Project > Clean in between, I was able to resolve these warnings.


for me this how I solve it:

  • go to the build path of the current project

under Libraries

  • select the "JRE System Library [jdk1.8xxx]"
  • click edit
  • and select either "Workspace default JRE(jdk1.8xx)" OR Alternate JRE
  • Click finish
  • Click OK

enter image description here

Note: make sure that in Eclipse / Preferences (NOT the project) / Java / Installed JRE ,that the jdk points to the JDK folder not the JRE C:\Program Files\Java\jdk1.8.0_74

enter image description here


Sorry for updating an old POST. I got the reported problem and I solved it as said below.

Assuming you are using Eclipse + m2e maven plugin, if you get this access restriction error, right click on the project/module in which you have the error --> Properties --> Build Path --> Library --> Replace JDK/JRE to the one that is used in eclipse workspace.

I followed the above steps and the issue is resolved.


In the case you are sure that you should be able to access given class, than this can mean you added several jars to your project containing classes with identical names (or paths) but different content and they are overshadowing each other (typically an old custom build jar contains built-in older version of a 3rd party library).

For example when you add a jar implementing:

a.b.c.d1
a.b.c.d2

but also an older version implementing only:

a.b.c.d1
(d2 is missing altogether or has restricted access)

Everything works fine in the code editor but fails during the compilation if the "old" library overshadows the new one - d2 suddenly turns out "missing or inaccessible" even when it is there.

The solution is a to check the order of compile-time libraries and make sure that the one with correct implementation goes first.


Go to the Java Build Path in the project properties. Remove the existing JRE System Library Then Add it again i.e. Add Library-->JRE Lib--select jre--->Finish. Lastly select order and export tab select JRE Lib and move on top. That's it.


Just change the order of build path libraries of your project. Right click on project>Build Path> Configure Build Path>Select Order and Export(Tab)>Change the order of the entries. I hope moving the "JRE System library" to the bottom will work. It worked so for me. Easy and simple....!!!


In my case there was a mismatch between the build path JRE and installed JRE on execution environment. I moved into Project > Properties > Java compiler. There was a warning message at the bottom.

I clicked on the links 'Installed JRE', 'Execution environment', 'Java build path' and changed the JDK version to 1.7 and the warning disappeared.


Adding a right JRE System through build path is the solution but your eclipse still may have the error. To solve that go to Java Build path --> Order and Export and move your JRE system library on the top. This has solved my problem.

참고URL : https://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar

반응형