How can I bundle a jar?including /res folder into thefinal jar using any bundler

I want to export my eclipse opengl project and this is working so far. But using jarsplice to bundle all libraries, natives and the main method to one final *.jar doesn’t work: the /res folder (including *.png’s and a 3dmodel cant be included into that *.jar.

Does anyone know a solution that esults in ONE *.jar with included data?

Thanks very much…

Within Eclipse, right click on the project, select Export…, choose either Jar or Runnable Jar, tinker with the options and export to your chosen path.

Then open the .jar with a zip manager, and see if you like the result.

In case you’re wondering, Runnable Jar only means that the Manifest declares the entry class.

There are more robust methods using command line, or MAVEN/ANT, but there are tutorials aplenty online for that, just keep this in mind: It looks harder than it really is.

I’m guessing that you are using Java’s File to load your resources, when loading resources from inside a jar you can’t you use File and need to use an InputStream.

I had issues loading resources from within the .jar once too, and this post helped:

From Stack Overflow:

[quote]It sounds like you’re then trying to load the resource using a FileInputStream or something like that. Don’t do that: instead of calling getResource, call getResourceAsStream and read the data from that.

(You could load the resources from the URL instead, but calling getResourceAsStream is a bit more convenient.)

EDIT: Having seen your updated answer, it seems other bits of code rely on the data being in a physical single file in the file system. The answer is therefore not to bundle it in a jar file in the first place. You could check whether it’s in a separate file, and if not extract it to a temporary file, but that’s pretty hacky IMO.
[/quote]