Java中的类JPEGImageEncoder,JPEGCodec和JPEGEncodeParam的导入问题

因为我要测试java的图片压缩,需要用这三个类,默认这三个类在eclipse是导不进来,直接报错的。

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

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

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

解决办法:

Eclipse默认把这些受访问限制的API设成了ERROR。只要把Windows-Preferences-Java-Complicer-Errors/Warnings里面的Deprecated and restricted API中的Forbidden references(access rules)选为Warning就可以编译通过。