使用Eclipse中的JAR导出图像(Java) [英] Exporting Images with JAR in Eclipse (Java)

查看:83
本文介绍了使用Eclipse中的JAR导出图像(Java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在做一个需要外部图像进行显示的小项目。我不是很熟悉如何使用Eclipse,这是我第一次尝试导出完成的项目,以便我可以与他人分享。现在,似乎我可以让我的图像显示出来的唯一方法是如果我在硬盘驱动器上分配一个特定的文件夹,并且代码中的图像路径就可以了。
我正在寻找一种将图像作为我的JAR的一部分导出或作为同一个包的一部分的方法,所以当我将这个程序发送给其他人时,我不必将它们单独存档图像文件夹。我也有兴趣学习我需要做的是让我的代码引用该包中的图像,以便它们在没有外部文件夹的情况下工作。
我已经阅读了Eclipse中的某种包装系统,但到目前为止,还没有运用它来确定如何使用它。可以使用一些解释!

I've been working on a little project that requires external images for display. I'm not all that familiar with how to use Eclipse and this is my first time attempting to export a completed project so I can share it with others. Right now, it seems the only way I can get my images to show up is if I assign a specific folder on my hard drive and have the image paths in the code go to that. I'm looking for a way to export the images as part of my JAR or as part of the same package so when I go to send this program to other people, I don't have to send them a separate archived folder of images. I'd also be interested in learning what I need to do to have my code reference the images within that package so they'll work without an external folder. I have read about some kind of package system within Eclipse, but have thus far had no luck in figuring out how to use it. Could use some explicating!

提前感谢任何愿意给我两分钱的人。

Thanks in advance to anyone willing to give me their two cents.

推荐答案

您可能需要将它们作为类路径资源加载到jar中。请参阅:getClass()。getClassLoader()。getResourceAsStream(...)

you might need to load them as class path resources if they are within a jar. see: getClass().getClassLoader().getResourceAsStream(...)

这篇关于使用Eclipse中的JAR导出图像(Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆