gpt4 book ai didi

java - 我需要什么库才能用 Java 访问这个 com.sun.image.codec.jpeg?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:51:40 25 4
gpt4 key购买 nike

我正在用 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

有人知道解决这个问题的方法吗,或者我应该添加什么库才能访问它以及我在哪里可以找到该库?

最佳答案

看这里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.

正如Milad建议的那样

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)

关于java - 我需要什么库才能用 Java 访问这个 com.sun.image.codec.jpeg?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8869912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com