LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: @ on October 13, 2013, 11:05:58

Title: Include everything in a jar
Post by: @ on October 13, 2013, 11:05:58
I'm looking for ways to include in one jar the lwjgl lib along its natives, so wherever i include this jar, the project runs under any so (at least in desktops). The wiki only explains the process for one SO, should i deploy a new jar for every SO? if i recall properly, libGDX lets you deploy in every SO.
Title: Re: Include everything in a jar
Post by: kappa on October 13, 2013, 15:19:39
have a look at JarSplice (http://ninjacave.com/jarsplice), it allows you to include everything in a jar.
Title: Re: Include everything in a jar
Post by: @ on October 13, 2013, 17:25:18
The tool comes in handy, but i'd rather know the process. Also, i prefer to set up eclipse (if possible) to save time, instead of using the tool everytime i want to deploy.
Title: Re: Include everything in a jar
Post by: @ on October 15, 2013, 13:19:20
I found a nice solution based on this blog post (http://frommyplayground.com/how-to-load-native-jni-library-from-jar/). For those interested, code is here (http://pastebin.com/iVmeB0iD) and is used like this:

Code: [Select]
NativeUtils.deleteOldDir();

final File parent = NativeUtils.createTempDir();

NativeUtils.loadLibraryFromJar(parent, "/natives/lwjgl.dll"); //For each library you need to add a new line like this.

System.setProperty("org.lwjgl.librarypath", parent.getAbsolutePath());
Title: Re: Include everything in a jar
Post by: NateS on October 26, 2013, 14:11:44
There is this:
https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglNativesLoader.java
It is based on SharedLibraryLoader which doesn't have any dependencies on libgdx.
https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/utils/SharedLibraryLoader.java