Setting Up LWJGL with Eclipse

This tutorial will run you through the steps you'll need to get LWJGL setup with the Eclipse IDE.

This can be tricky if you are not familiar with the IDE because unlike most Java libraries LWJGL has two parts, a Java part (lwjgl.jar) and a native code part (*.dll files for Windows, *.so files for linux and *.dylib/*.jnilib for Mac). Both parts must be set in order to use the library.

Firstly download LWJGL from its sites download page. You'll just want the standard download bundle (lwjgl-x.x.zip), you can ignore the source, docs and applet bundles for now.

Extract the contents of the bundle to somewhere on your computer, it does not have to be in any specific location. Do not put it in the Java installation directory.

Next start up Eclipse and create a new project.



Then right click the project and choose properties.



Next select 'Java Build Path' and then the 'Libraries' tab.



Add lwjgl.jar as an external jar by clicking the 'Add External Jars..." button.



If you intend to use OpenGL's GLU class you should also add lwjgl_util.jar. If you are using the Slick2D library then you should also add slick.jar here.

Finally we need to setup the native component of LWJGL. This is done by clicking the little arrow next to the lwjgl.jar file to show the drop down list. Double click 'Native library location' and select the folder that contains the native files for your operating system and clicking OK. These are located in the natives folder include in the LWJGL download bundle (e.g. On Windows you'd point to the natives\windows folder which contains the *.dll files, On Mac you'd point to the natives/macosx folder and on Linux you'd point to the natives/linux folder).



That's it, you now have LWJGL setup with Eclipse and can begin coding.

Tutorial Credit - Ninja Cave