无法在最新的JVM版本上加载JAR的资源
从JAR文件(png构建Imageicon)加载资源文件效果很好18年。仍然可以使用热点Java版本“ 1.8.0_333”。使用热点Java版本“ 18.0.1.1”运行,无法加载资源...所有这些都用同一JAR文件,我确实检查并包含了资源文件。
String fileName = "/images/logo.png";
ImageIcon image = new ImageIcon();
byte[] imageBytes = null;
InputStream in = image.getClass().getResourceAsStream(fileName);
if (in == null) {
System.out.println("could not find " + fileName);
}
以上 - 代码片段。在使用18.0.1.1时,在实际上是无效的...任何人都看到了从一个版本到另一个版本的处理getResourceasstream的差异吗?
Loading resource files from a jar file (a png to build an ImageIcon) worked well for 18 years. Still works with Hotspot java version "1.8.0_333". Running with Hotspot java version "18.0.1.1" fails to load the resource... All this with the same jar file, that I did check and contains the resource file.
String fileName = "/images/logo.png";
ImageIcon image = new ImageIcon();
byte[] imageBytes = null;
InputStream in = image.getClass().getResourceAsStream(fileName);
if (in == null) {
System.out.println("could not find " + fileName);
}
Above - code snippet. in is effectively null when using 18.0.1.1... Anyone has seen difference in processing getResourceAsStream from one version to the other ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论