Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access
Posted yutingliuyl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access相关的知识,希望对你有一定的参考价值。
准备使用Java进行图片压缩的时候,使用

将 Deprecated and restricted API 中的 Forbidden references(access rules) 选为Warning就能够了。
import com.sun.image.codec.jpeg.*;
结果出现错误:
Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not accessible due to restriction on required library上网查了一下。发现是IDE的设置问题。它默认把这些受訪问限制的API设成了ERROR
解决方法:
Windows->Preferences->Java->Complicer->Errors/Warnings以上是关于Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access的主要内容,如果未能解决你的问题,请参考以下文章