Java中Access restriction:····的解决方法

Posted cuizhf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java中Access restriction:····的解决方法相关的知识,希望对你有一定的参考价值。

http://blog.csdn.net/bit2012_2015/article/details/22798779

————————————————————————————————————————————————————

问题原因:Eclipse 默认把这些受访问限制的API设成了ERROR

 

解决方法:

1.      Windows-> Preferences -> Java -> Compiler -> Errors/Warnings ->Deprecatedand trstricted API -> Forbidden reference (access rules): -> change towarning

2.      只需要在projectbuild path中先移除JRESystem Library,再添加库JRESystem Library,重新编译后就一切正常了。

3.      工程上右键->工程属性->javabuilder path->Libraries标签,点击JRE SystemLibrary里面的Accessrules,addsun/** 为accessible,如果该项存在,就edit。

4.      Windows-> Preferences -> Java -> Installed JREs -> 选择用的JDK-> Edit -> Add External JARs

以上是关于Java中Access restriction:····的解决方法的主要内容,如果未能解决你的问题,请参考以下文章

Access restriction required library rt.jar

Access restriction: SSLSocket is not accessible due to restriction issue

Java,AWTUtilities,eclipse报编译错误:Access restriction: The type 'AWTUtilities' is not API (restr

Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required libra

Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access

Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:Pr(