Java处理图片时编译不通过

Java中处理图片时,MyEclipse需要导入以下包:

  import com.sun.image.codec.jpeg.JPEGCodec;
  import com.sun.image.codec.jpeg.JPEGEncodeParam;
  import com.sun.image.codec.jpeg.JPEGImageEncoder;

但编译器报错,错误信息:

Access restriction: The type JPEGCodec is not accessible due to restriction on required library/home/dsp/Applications/MyEclipse/binary/com.sun.java.jdk7.linux.x86_64_1.7.0.u45/jre/lib/rt.jar

Access restriction: The type JPEGEncodeParam is not accessible due to restriction on required library /home/dsp/Applications/MyEclipse/binary/com.sun.java.jdk7.linux.x86_64_1.7.0.u45/jre/lib/rt.jar

Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library /home/dsp/Applications/MyEclipse/binary/com.sun.java.jdk7.linux.x86_64_1.7.0.u45/jre/lib/rt.jar

解决办法:

  MyEclipse默认把这些受访问限制的API编译级别设置为:ERROR,只需把:Window -> Preferences -> Java -> Complicer -> Errors/Warnings

  选项 Deprecated and restricted API 中的 Forbidden references(access rules) 由 Error 设置为 Warning 即可编译通过!

^_^

上一篇:json解析之C++库nlohmann / json


下一篇:Selenium2(WebDriver)总结(五)---元素操作进阶(常用类)