LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: blobjim on October 30, 2016, 22:33:05

Title: How do I setup natives when they are in jars?
Post by: blobjim on October 30, 2016, 22:33:05
Do I need to extract all of the natives from their jars and put them in a separate folder?
I have lwjgl, glfw, and opengl added to the build path in Eclipse.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
   at java.lang.Runtime.loadLibrary0(Runtime.java:870)
   at java.lang.System.loadLibrary(System.java:1122)
   at org.lwjgl.system.Library.loadSystem(Library.java:104)
   at org.lwjgl.system.Library.<clinit>(Library.java:48)
   at org.lwjgl.system.MemoryAccess.<clinit>(MemoryAccess.java:18)
   at org.lwjgl.system.Pointer.<clinit>(Pointer.java:22)
   at org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:76)
   at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:563)
   at main.TriangleDemoOpenGL.main(TriangleDemoOpenGL.java:28)
Title: Re: How do I setup natives when they are in jars?
Post by: kappa on October 30, 2016, 22:36:49
nope, just add all the jars you need with the corresponding native jars to the classpath. The rest is all handled automatically by LWJGL's SharedLibraryLoader (you do not need to set a path to the natives manually).
Title: Re: How do I setup natives when they are in jars?
Post by: blobjim on November 02, 2016, 04:54:47
I don't quite understand what you mean. I've added the library jars to the eclipse build path, but I don't want to have to manually add every single natives jar to the build path.
Title: Re: How do I setup natives when they are in jars?
Post by: seventh-chord on November 02, 2016, 05:46:32
You have to add all the native jars for the sub-components of lwjgl you need, there is now way around it. But you should not have to manually do it. I have no experience with eclipse, but you should be able to add all the jars to a folder (eg. project-folder/lib) and then add all jars in that folder to your project in one swoop. Alternatively, you might want to check out maven or gradle, both of which can automatically manage your dependencies for you. The lwjgl website includes snipets for using both of these tools.
Title: Re: How do I setup natives when they are in jars?
Post by: blobjim on November 03, 2016, 02:46:09
Alright, thank you guys for the responses. I finally discovered that you can ctrl-click jars when selecting libraries to add to the classpath in Eclipse.  :P