Search code examples
javajarexportgame-enginelwjgl

Export LWJGL Game Engine as (Not Runnable) JAR


I am working on a LWJGL game engine. I want to export the engine as a JAR file that can be utilized in the build path of other projects. I tried using JarSplice to pack in all of the natives, but I am still getting an error when I try to use the engine packed in a jar in a different project.

When I export the engine as a JAR, move it to the build path of another project, and try to run, I am getting an UnsatisfiedLinkError when the JAR engine tries to create an OpenAL instance with AL.create(). From what I'm reading, this is an error with the natives, though I could be wrong in this instance.

How can I export my engine as a jar so it can be used in other projects?


Solution

  • With LWJGL 2.x the user of your engine will always have to manually add the natives to the game's native path. They will not get extracted automagically from jar files. The current LWJGL 3 on the other hand provides such functionality and allows you to distribute your engine together with the LWJGL dependency as a jar file. It does this by searching the classpath for the native files and extracting them to a temporary folder and loading them there.