[英]com.sun.imageio.plugins.jpeg.JPEGImageReader no longer part of JDK-11
I am trying to migrate a project from JDK8 to JDK11, the issue is that most of the things are no longer part of JDK11 as they used to be in JDK8. 我正在尝试将项目从JDK8迁移到JDK11,问题是大多数事情不再像以前在JDK8中那样成为JDK11的一部分。 There are some separated jars that I had to add manually due removal of those packages from JDK11, but one issue remains.
由于从JDK11中删除了这些软件包,我不得不手动添加一些分离的jar,但是仍然存在一个问题。 The import com.sun.imageio.plugins.jpeg.JPEGImageReader;
导入com.sun.imageio.plugins.jpeg.JPEGImageReader; is no longer part of JDK11 and I am not able to find proper replacement or dependency in order to provide to my code so it can work as it used to.
不再是JDK11的一部分,并且我无法找到适当的替换或依赖项来提供给我的代码,因此它可以像以前一样工作。
I've visited docs https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/imageio/package-summary.html but they do not seem like a proper replacement 我访问了docs https://docs.oracle.com/zh-CN/java/javase/11/docs/api/java.desktop/javax/imageio/package-summary.html,但它们似乎不是适当的替代品
InputStream iccProfileStream = JPEGImageReader.class.getResourceAsStream("/ISOcoated_v2_300_eci.icc");
//the JPEGImageReader is completely red due missing jar that was removed from JDK11 //由于缺少从JDK11中删除的jar,因此JPEGImageReader完全是红色的
cmykProfile = ICC_Profile.getInstance(iccProfileStream);
iccProfileStream.close();
Code should compile as it used to do on JDK8 but instead, it keeps popping an error "package com.sun.imageio.jpeg is not visible (package com.sun.imageio.plugins.jpeg is declared in module java.desktop, which does not export it )" 代码应该像以前在JDK8上一样进行编译,但相反,它始终弹出错误消息“包com.sun.imageio.jpeg包不可见(包com.sun.imageio.plugins.jpeg在模块java.desktop中声明,不导出)”
It doesn't seem that you even need that class, at least based on the code you're showing. 似乎至少基于所显示的代码,您甚至都不需要该类。
Instead of JPEGImageReader.class.getResourceAsStream(..
, you can use any Class
object as long as it's in the suitable classloading context. The getResourceAsStream
method exists in the Class
class. 可以使用任何
Class
对象来代替JPEGImageReader.class.getResourceAsStream(..
,只要它在合适的类加载上下文中即可getResourceAsStream
方法存在于Class
类中。
Replace it with getClass().getResourceAsStream(..
and that part of the code will work just fine. 将其替换为
getClass().getResourceAsStream(..
,那部分代码就可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.