Add resources into a jar upon building
I want to add DLL's, images, textfiles etc to my project as resources so when I export it, the jar contains the resources so they can be used. I am using eclipse. Problem is I have no idea how to add it. I've tried adding DLLs/pics to the src folder in the project, but when I export the jar, it is not located there
I've looked at How to make a JAR file that includes DLL files? but it only explains how to extract it, not how to add it to the project and build.
EDIT: I am using an applet to open the jar by the way, sorry for missing it开发者_如何学Go!
Cheers
How are you opening the file in java? Class.getResourceAsStream(name)?
If you are packaging the code in a jar, then you need to use that command. (as opposed to new File(name), which will get the file in the same directory as your jar)
If the file is not physically in your jar, you can check by changing .jar to .zip and extracting it, then check out this doc http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html
Usually in an eclipse project, the src
folder is the wrong place to put non-sourcecode-content.
You should try moving to maven as your build system, as it is highly customizable and provides you with folders inside your project for exactly that purpose. (src/main/resources)
精彩评论