eclipse import错误

来源:互联网 发布:一个矩阵的值怎么算的 编辑:程序博客网 时间:2024/05/17 06:57

在eclipse中处理图片,需要引入两个包: 
引用
import com.sun.image.codec.jpeg.JPEGCodec; 
import com.sun.image.codec.jpeg.JPEGImageEncoder;


但eclipse始终报错: 
引用
Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library %JAVA_HOME%\lib\rt.jar




可是rt.jar中明明有这个类,为何呢?


仔细看报错的内容 访问受到了限制
eclipse的编译器里的 访问规则 问题
默认的将 禁止访问的api 设为了 ERROR,所以会报错


怎么办?


Windows---->Preferences---->Java---->Complicer-Errors/Warnings
   Deprecated and restricted API-->Forbidden references(access rules)
   将Error改为Warning就可以编译通过。





0 0