简体   繁体   English

将带有想象的 java 正文导出到带有图像的 jar 中

[英]Exporting java body with imagine into jar w/ images

I wrote code that works whenever i run in Eclipse, but whenever i try to export it into a runnable Jar, my images dont show up.我编写的代码在 Eclipse 中运行时可以正常工作,但是每当我尝试将其导出到可运行的 Jar 中时,我的图像都不会显示。

For my images this is the code being used pic1=ImageIO.read(FourCournersRunner.class.getResource("/Images/1.png"));对于我的图像,这是正在使用的代码pic1=ImageIO.read(FourCournersRunner.class.getResource("/Images/1.png")); When exporting the project I've chosen "Package required libraries into generated JAR":导出项目时,我选择了“将所需的库打包到生成的 JAR 中”:

  1. Please also show the code where you display the image in GUI, the problem might lie in there.还请显示您在 GUI 中显示图像的代码,问题可能出在那里。
  2. Did you also package the Images folder to the .jar file?您是否也将Images文件夹打包到 .jar 文件中?
  3. The problem might be caused by the way you set up build path too.问题也可能是由您设置构建路径的方式引起的。

In short, I don't think the code you provide right now can reproduce the problem.简而言之,我认为您现在提供的代码无法重现该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM