Access restriction: The type XXX is not accessible due to restriction on require
引用rt.jar中的一个类,结果发生了标题中的错误
"Access restriction: The type XXX is not accessible due to restriction on required library c:\jdk\jre\lib\rt.jar "
这个类应该没有什么问题的,估计是eclipse编译器的问题,网上查资料,发现eclipse中此类的问题不少,摘录一篇解决方法:
http://blog.****.net/hexin373/article/details/7175325
ibrary C:\Program Files\Java\jdk\jre\lib\ext \jdsmsserver-3.4.jar google了一下 下面是解决方法 Eclipse 默认把这些受访问限制的API设成了ERROR。只要把Windows-Preferences-Java-Complicer- Errors/Warnings里面的Deprecated and restricted API中的Forbidden references(access rules)选为Warning就可以编译通过。
不过这个不好
如果你的jre目录里面有你项目需要引用的jar包 而你又引用了外部jar包 也就是说引用了两次
如果你想让起作用的是手动引用的外部jar包 这个时候需要把 "Referenced Library" 调整到 "JRE System Library"上面
改变顺序前的效果:
build path
最后效果
OK 一切正常... |