I am working on a project in which I use image files. Where is the proper location to store the folder with the images? Inside src folder (created by netbeans) or outside? Also when I clean and build the project a dist folder is created with the jar file in it. Can the images folder be included in the jar or I have to copy them in the same folder with the jar if I want to run the program on another computer? Finally, I would like to know how to use the getResource when I want to refer to the image folder from the source code. Thanks in advance.
相关问题
- Views base64 encoded blob in HTML with PHP
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to get the background from multiple images by
The answer is, it depends. If you want the images bundled within the Jar (AKA embedded resource), then they should be stored within the Netbeans
src
directory. If you want them stored externally (and you will then become responsible for ensuring that they are included with the Jar when you deploy it), then they should be stored outside thesrc
directory.If the images are stored within the
src
directory, they are included automatically, if they stored externally, you will need to provide some custom ant code to perform the required actions you want.Again, if they are stored externally (to the
src
directory), you become fully responsible for their managementThere are a number of resources/examples available which can expand on the individual requirements/differences in how to use
getResource
in different scenarios, but that's the basic idea