[LWJGL] Specifying JAR's LWJGL Library [Cross Platform]

I have tried the following to detect what libs are needed, and it works great in Eclipse, however I can NOT get this to work as an exported JAR.

System.setProperty("org.lwjgl.librarypath", new File("/lib/native/" + (System.getProperty("os.name").toLowerCase().contains("win") ? "windows" : "linux") + "/").getAbsolutePath());

I have also tried :
The ./

System.setProperty("org.lwjgl.librarypath", new File("./lib/native/" + (System.getProperty("os.name").toLowerCase().contains("win") ? "windows" : "linux") + "/").getAbsolutePath());

Running it on Windows I get the following:

C:\Users\Nanoscape\Desktop>java -jar Rabits.jar
Exception in thread “main” java.lang.UnsatisfiedLinkError: Can’t load library:
C:\Users\Nanoscape\Desktop.\lib\native\windows\lwjgl64.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:70)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:87)
at org.lwjgl.Sys.(Sys.java:117)
at org.lwjgl.opengl.Display.(Display.java:135)
at renderEngine.DisplayManager.(DisplayManager.java:13)
at engineTester.RunGame.main(RunGame.java:13)

Which translates to me the code is not working…
It also shows the .\ in the error even if I have the path without the .
Any ideas? It is probably something really simple and I blew over it…

Any help is appreciated!

This is what I use

System.setProperty("java.library.path", System.getProperty("java.library.path") + ";libraries/native/" + LWJGLUtil.getPlatformName() + "/" + (System.getProperty("os.arch").contains("64") ? "x64" : "x86"));

which I suppose would be

System.setProperty("java.library.path", System.getProperty("java.library.path") + ";libraries/native/" + LWJGLUtil.getPlatformName()

before LWJGL 3.

Can’t use [icode]File[/icode] for things inside a jar (or any archive).

If File can not be used, what can I use? :-\

You have to use a resource. Google “java jar resource” for a ton of results.

That being said, I’m not sure you can use a resource (a file inside a jar) as a native library. I think you have to export it to a file (outside the jar) first. One solution is to extract the native files to a temp directory before running the program.

Shameless self-promotion: Jar Matey (say it like a pirate) does all of the above.

I have tried similar solutions in the past,
trying to avoid it if possible.

Nice name though! Love it! ;D

Sadly, I don’t think it is avoidable, since native libraries need to be on the file system, not in a jar.