Java & Eclipse: Resources in JAR?

2019-02-26 18:28发布

问题:

How can I add resources (images) directly into my JAR file? For example, if you open the minecraft.jar (of Minecraft) you can see a few classes and folders with resources.

If I try to put any resources in my /src folder, Eclipse will show them in the Package Explorer which is annoying.

When I decompile Minecraft (Minecraft Coder Pack) there are no resources in the /src folder. How can I add my resources like Minecraft does?

Thanks in advance!!

回答1:

You can just create a new folder and mark it as source folder (rightclick on folder in Eclipse -> Build Path -> Use as source folder). Now you should be able to use the ressources without them being in the /src folder.