使用JPEGImageEncoder提示Access restriction:錯誤
當咱們在對圖片進行操做時,須要使用到 eclipse
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam jep = JPEGCodec.getDefaultJPEGEncodeParam(tag);
這個時候eclipse會報錯: ui
Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
Access restriction: The type JPEGCodec is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
Access restriction: The method encode(BufferedImage) from the type JPEGImageEncoder is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
rest
這個事eclipse的設置問題,它默認把這些受訪問限制的API設成了ERROR,你只要把
Windows-Preferences-Java-Complicer-Errors/Warnings
裏面的Deprecated and restricted API中的Forbidden references(access rules)選爲Warning就能夠編譯經過了。 code