我需要什么库,所以我可以在Java中访问这个com.sun.image.codec.jpeg?

前端之家收集整理的这篇文章主要介绍了我需要什么库,所以我可以在Java中访问这个com.sun.image.codec.jpeg?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 java中创建一个图像水印程序,我导入了以下内容
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 accesible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar

有人知道一种方法解决这个问题,还是需要添加哪些图书馆才能访问该图书馆?

@H_502_17@解决方法
看看这里 Link
1. Open project properties.
2. Select Java Build Path node.
3. Select Libraries tab.
4. Remove JRE System Library.
5. Add Library JRE System Library.

正如米拉德所说

Even though this WILL work,this goes against all recommended Java Runtime policies. The best practice is to avoid using rt.jar (or any other Sun supplied runtime library for that matter,like tools.jar)

原文链接:https://www.f2er.com/java/121191.html

猜你在找的Java相关文章