简体   繁体   中英

Where is the right way that should you put your resources (i.e Images and Sound files) when trying to create a JAR file?

I am using Intellij IDEA and whenever I build a JAR artifact it places itself on the productions folder. When I try to run the JAR file some custom defined functions (ie setting Icons on Components and adding sounds) are missing, while running it on the Intellij's IDEA is functioning correctly. I know that it involves using getResourceAsStream method but is there some sort of right way to place external resources?

Additional questions I may add, where is the correct destination for placing the META-INF folder? Should I make a resource folder for all my external files?

This is for Eclipse users, I believe the same thing can be accomplished in other IDE's relatively easily.

  • Create a resources folder
  • Put your non-code files in it
  • Use as "Source Folder"

在此处输入图像描述

After creating the JAR, the contents of "resources" will be packed in the JAR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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