How to set up an LWJGL project

Hi guys,

I am looking to begin OpenGL programming but I am having trouble compiling a project using the LWJGL 3.1.1 library Jar files. My trouble seems to be with the native library files.

I have downloaded the “minimal OpenGL” zip bundle and added the LWJGL, OpenGL and GLFW Jar files (classes, source and natives) as shown in the following picture.

I have attempted to run the basic “Getting Started” code from the LWJGL website, it compiles successfully, but if I try to run the project I get the following error message:

After some investigation I have found that I need to point the project to the location of the native files using the “Djava.library.path” argument in the “Run Configuration” screen. I have tried setting this argument to my project’s “lib” folder containing the library JAR files, but this did not work. I also noticed that the LWJGL Wiki provides the following information:

“The LWJGL native shared libraries do NOT need to be extracted from their .jar files. The SharedLibraryLoader that is included with LWJGL does it automatically at runtime.”

…but I do not know how to use the SharedLibraryLoader, or what it really is for that matter…

Is anyone able to show me what I am doing wrong? Maybe provide a screenshot of your library/run configuration screens of a working project?

Thanks in advanced guys!

Looks like the same issue: http://forum.lwjgl.org/index.php?topic=6428.0

The -native-.jar files aren’t native libraries. They only contain native libraries. Add them to “Classes” instead, just like the other .jar files, and it should work.

You’ve already got the answer, but I’d just like to expand on it a bit for clarity.

The java.library.path is what you use when you are working directly with native shared libraries (such as glfw3.dll on Windows, or glfw3.so on Linux/*BSD, or glfw3.dylib on OS X) directly. It is not for jar files.

[quote]I also noticed that the LWJGL Wiki provides the following information:

“The LWJGL native shared libraries do NOT need to be extracted from their .jar files. The SharedLibraryLoader that is included with LWJGL does it automatically at runtime.”

…but I do not know how to use the SharedLibraryLoader, or what it really is for that matter…
[/quote]
You don’t have to worry about SharedLibraryLoader. Read again what you quoted: “LWJGL native shared libraries do NOT need to be extracted from their .jar files” and “LWJGL does it automatically at runtime.”

The native libraries you need are bundled up with the LWJGL distribution in jar files. At runtime, LWJGL extracts them from the jars and loads them into your process. LWJGL is using Java resource streams to load the jar files and extract the libraries (via its SharedLibraryLoader class, which again, you don’t have to worry about), so like any other bundled resource jars, they need to be on the classpath.

Thank you so much for the responses guys! Everything is working well now ;D

I appreciate the extra information aldacron.