1. 程式人生 > >Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access

Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access

rac err ssi cte encode rar eth -a gen

準備使用Java進行圖片壓縮的時候,使用
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
技術分享

將 Deprecated and restricted API 中的 Forbidden references(access rules) 選為Warning就能夠了。

Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not access