In Java, where in the package/source hierarchy should resources be placed?
java, package, resources
Solution
I have seen this handled in a number of different ways:
Place your resources directly in a subdirectory under `com/dmxio/games/breakout` (e.g. `/com/dmxio/games/breakout/images/foo.gif` and `/com/dmxio/games/breakout/images/bar.gif`)
Place your resources in a jar along with your class files (e.g. `foo.gif` and `bar.gif` bundled in `breakout.jar`)
Place your resources in a separate 'resources jar' in a subdirectory under `com/dmxio/games/breakout` (e.g. `foo.gif` and `bar.gif` bundled in `/com/dmxio/games/breakout/images/images.jar`)
I tend to favor the last option.
You can then use the `java.lang.Class.getResource()` method to retrieve your resources.
Problem
Say I have developed a game, and placed it in the package structure: ``` com.dxmio.games.breakout ``` Where then is the 'best practice' place to put resources like audio and images that the game uses?