I'm still experimenting with some OpenGL in LWJGL, and as I get to know more and more about OpenGL, I start to do more complicated things like multi texturing, shadowmapping and more. Now, right now I'm using the src folder (src/res) for my resources, and use src/resourcename in my code. When I export it, this won't work on another location as the relative path is ofcourse incorrect. What would be the best way of deploying your game with all the resources in one file? Maybe put the files in the jar?

I would like to hear from a few people how they store and deploy their project with resources, thanks!

  • \$\begingroup\$ This isn't such a great fit for Q&A; we try to avoid listing resources and the like that are too, too bias. \$\endgroup\$ Mar 13, 2013 at 13:51

1 Answer 1


Don't put the resources in your source folder. Instead do something like this:

  • Project root
    • src
    • res
      • images
      • shaders
      • sounds

There are two common ways to load resources in Java applications.

1. File system

In the code you can load the resources from file system with relative path "res/images/filename.png". While developing, use Project root as the working directory. When deploying the project, just copy the res folder to the same folder where the executables are located. You can also omit the res folder if you want to or call it something else.

2. JAR resources

Add the res folder to your classpath. You can then load the resources using ClassLoader.getResourceAsStream("images/filename.png"). Note the missing res folder from the path. When deploying, add the content of res folder to your .jar file.

It's also possible to put local resources next to the source files even deep in the package hierarchy. These resources can be loaded with Class.getResourceAsStream("relativepath"), where path to the resource is relative to the package of the class calling this method. I would not recommend this approach for game assets.

If the resources are considered as read-only after deployment, I would recommend the second approach. If on the other hand the player is allowed to modify or add resources to the game, the first approach works better.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .