简体   繁体   English

Java和Eclipse:JAR中的资源?

[英]Java & Eclipse: Resources in JAR?

How can I add resources (images) directly into my JAR file? 如何将资源(图像)直接添加到我的JAR文件中? For example, if you open the minecraft.jar (of Minecraft) you can see a few classes and folders with resources. 例如,如果您打开Minecraft.jar(Minecraft),您可以看到一些包含资源的类和文件夹。

If I try to put any resources in my /src folder, Eclipse will show them in the Package Explorer which is annoying. 如果我尝试将任何资源放在我的/ src文件夹中,Eclipse会在Package Explorer中显示它们,这很烦人。

When I decompile Minecraft (Minecraft Coder Pack) there are no resources in the /src folder. 当我反编译Minecraft(Minecraft Coder Pack)时,/ src文件夹中没有资源。 How can I add my resources like Minecraft does? 我怎样才能像Minecraft一样添加我的资源呢?

Thanks in advance!! 提前致谢!!

You can just create a new folder and mark it as source folder (rightclick on folder in Eclipse -> Build Path -> Use as source folder). 您可以创建一个新文件夹并将其标记为源文件夹(右键单击Eclipse中的文件夹 - >构建路径 - >用作源文件夹)。 Now you should be able to use the ressources without them being in the /src folder. 现在你应该可以使用ressource而不将它们放在/ src文件夹中。

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

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