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

转:

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

 更新时间:2018年02月14日 17:13:03   投稿:wdc   我要评论
 
Java开发中对图片的操作需要引入 com.sun.image.codec.jpeg,但有时引入这个包会报错,利用下面的操作可以完成解决这个问题

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

?
1
2
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

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

?
1
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报错问题。

推荐方法二

猜你喜欢

转载自www.cnblogs.com/libin6505/p/11956226.html