欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Eclipse中引入com.sun.image.codec.jpeg包报错的完美解决办法

程序员文章站 2023-01-15 08:13:01
在eclipse中开发javat程序处理图片时,需要引入两个包: import com.sun.image.codec.jpeg.jpegcodec; impo...

在eclipse中开发javat程序处理图片时,需要引入两个包:

import com.sun.image.codec.jpeg.jpegcodec;
import com.sun.image.codec.jpeg.jpegimageencoder;

但有时引入这个两个包时会报出错误:

access restriction: the type jpegimageencoder is not accessible due to restriction on required library c:/java/jre1.6.0_07/lib/rt.jar

出现这个错误的主要原因是eclipse中的访问限制问题,可以通过下面两种方法解决:

一、全局属性preferences>java>compiler>errors/warnings>把右侧的“deprecated and restricted api>forbidden reference的error” 置为“warning”。

二、项目属性preferences>java build path>把右侧【libraries中的jre system library】删除重新导入。

上面两种方法都可以解决 eclipse 引入 com.sun.image.codec.jpeg报错问题。如还不能解决问题请联系我们