问题:import com.sun.image.codec.jpeg.JPEGCodec 出现错误
在Java中处理图片,需要引入两个包:
import com.sun.image.codec.jpeg.JPEGCodec;
importcom.sun.image.codec.jpeg.JPEGImageEncoder;
但是发现会报错,错误信息如下:
Access restriction: The typeJPEGImageEncoder is not accessible due to restriction on required library H:/Programfiles/Java/jdk1.6.0_24/jre/lib/rt.jar
解决办法:
MyEclipse默认把这些受访问限制的API设成了ERROR,只要设置一下就OK了。
设置方法如下:
Windows------->Preferences------->Java------->Complicer------->Errors/Warnings里面的Deprecatedand restricted AP------->Forbidden references(access rules) ------->选为Warning------->出现询问是否重新编译的对话框------->点击确认------->编译通过。
如图:
参考资料:http://blog.youkuaiyun.com/oney139/article/details/6539624