I tend to support both filesystem loading and classpath loading myself; gives freedom between "development mode" (in which I can set a working directory for the project in the IDE and switch that around when I'm experimenting) and "deployment mode" (all resources in the game jar). Something like:
1 2 3 4 5 6 7 8 9
| InputStream is = null;
File fp = new File("somepath/somefile.png");
if(fp.isFile()){ is = new FileInputStream(fp); } else { is = getClass().getClassLoader().getResourceAsStream("somepath/somefile.png"); } |
Insert exception handling and resource closing code. As an added "bonus" this strategy gives me the opportunity to override resources in the jar without having the replace them, which helps to debug problems with game resources in a more "live environment" - for example I can instruct someone that is testing to put a piece of game script or whatever in a specific place to see if that changes anything, without having to provide an updated jar first.