java - OpenJDK 8 中 ImageIO.read 错误的解决方法?

标签 java image openjdk unsatisfiedlinkerror

我正在为一个项目使用 Java 8(特别是 OpenJDK 8),我需要从 JPG 文件中读取图像。一开始我四处搜索得到了一些类似的问题(例如 Read byte array into buffered image WITHOUT ImageIOIs there a 100% Java alternative to ImageIO for reading JPEG files? ),但我的问题是不同的,那里的解决方案不符合我的要求。

事实证明,JPEGImageReader 类仍然缺失。 (参见 openjdk-8: Missing JPEGImageReader functions in libjavajpeg.so)尽管该错误报告是针对 Debian 的,但我使用的是 Kubuntu 14.10,它也受到了影响。

根据报告的最后一条消息,此时似乎没有人在处理此问题...

重现此错误的代码片段是:

// ...
BufferedImage img = null;
try {
    img = ImageIO.read(new File(filename));
} catch (IOException e) {
    throw new RuntimeException(e);
}
// ...

文件的路径是有效的,如果我使用 Java 1.7,它可以正常工作,但是更改为 1.8 会导致 ImageIO.read 调用出现以下异常:

Caught UnsatisfiedLinkError: com.sun.imageio.plugins.jpeg.JPEGImageReader.initReaderIDs(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;)

我想帮助解决这个问题,同时避免:

  1. 对其他/外部库的额外依赖;
  2. 回到 Java 1.7;
  3. 必须从源代码重建;
  4. Oracle 专有的 JDK 实现

感谢工作代码片段。

EDIT-1:在列表中添加了第 4 点。

EDIT-2:改写了主要部分的一部分并添加了另一个引用。

最佳答案

根据 Matthias Klose 的 email,我相信自 2015 年 3 月 17 日发布以来,此问题已得到修复:

Source: openjdk-8 Source-Version: 8u40-b27-1

We believe that the bug you reported is fixed in the latest version of openjdk-8, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is attached.

Thank you for reporting the bug, which will now be closed. If you have further comments please address them to 760926@bugs.debian.org, and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software pp. Matthias Klose (supplier of updated openjdk-8 package)

(This message was generated automatically at their request; if you believe that there is a problem with it please contact the archive administrators by mailing ftpmaster@ftp-master.debian.org)

关于java - OpenJDK 8 中 ImageIO.read 错误的解决方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28664812/

相关文章:

gradle - 如何让 android studio (gradle) 使用 Sun/Oracle Java?

java - 如何在 Java 中实现 IBM MQ 逻辑排序?

java - 使用 maven exec :java plugin under Windows 的 JSP 的类路径问题

javascript - HTML 加载图像 : Is my algorithm producing too much traffic?

iphone - 在 iPhone 的 UIImageView 中显示图像

html - 垂直对齐 :middle problem in ie

java - 如何知道我使用的是 Open JDK 还是 Oracle JDK?

java - 在没有密码学库的情况下在 Java 中实现 DSA 的问题

JavaFX drawImage 旋转

java - OpenJDK - 准备好投入生产了吗?