Skip to content
SilverTiger edited this page Dec 21, 2014 · 20 revisions

This small guide is just to show you how to setup LWJGL3.

Downloading LWJGL3

  1. The very first step is of course downloading the library, you can get it here.
    Currently there is no release version, so get the stable or the nightly version.
  2. After that just extract the lwjgl.zip file to any location you want it to be.
  3. You should now have the folders doc, jar and native and a file src.zip.

Setting up your favorite IDE

Now that you have downloaded the library start up your IDE.

NetBeans

You have to do the following steps just once.

  1. Go to Tools -> Libraries
  2. Click on New Library
  3. Type any name for the library like LWJGL3
  4. Select the newly made library
  5. At the Classpath tab click on Add JAR/Folder... and go into the folder where you extracted the lwjgl.zip and go into the jar folder and select lwjgl.jar and disruptor.jar
  6. At the Source tab click on Add JAR/Folder... and go into the folder where you extracted the lwjgl.zip and select src.zip
  7. At the Javadoc tab click on Add ZIP/Folder... and go once again in the folder where you extracted lwjgl.zip and go into the doc folder and select javadoc.zip

Now you can create a new project to test your setup. The following steps have to be done at each project.

  1. Create a new Java Application project via File -> New project...
  2. In your project right-click on Libraries and select Add Library...
  3. Of course select your LWJGL3 library
  4. Now right-click your project and click on Properties
  5. Go to the Run category
  6. Click into VM Options and type -Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native/<os>/<arch>" where <os> is either windows, linux or macosx and <arch> is either x86 or x64, depending on your system.
    Note that you could also just use -Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native and LWJGL3 will choose the right path for you.

Eclipse

The following steps have to be done for each project.

  1. Create a new project via File -> New -> Java Project
  2. Right-click your project and select Properties
  3. Go into the Java Build Path category
  4. Select the Libraries tab
  5. Click on Add External Jars..., then go to your folder where you extracted lwjgl.zip and go in the jar folder and select lwjgl.jar and disruptor.jar
  6. Expand lwjgl.jar
  7. Select Source attachment and click on Edit...
  8. Click on *External File... and go to your folder where you extracted lwjgl.zip and select src.zip
  9. Select Javadoc location and click on Edit...
  10. Click on Browse... next to Archive path, go to your folder where you extracted lwjgl.zip and into the doc folder and select javadoc.zip
  11. Now in your main menu select Run -> Run Configurations...
  12. Select the Arguments tab
  13. Click into VM arguments and type -Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native/<os>/<arch>" where <os> is either windows, linux or macosx and <arch> is either x86 or x64, depending on your system.
    Note that you could also just use -Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native and LWJGL3 will choose the right path for you.

IntelliJ

The following steps have to be done for each project.

  1. Create a new Java project via File -> New Project
  2. In your main menu select File -> Project Structure
  3. Select the Modules category
  4. Select the Dependencies tab
  5. Click on the green + -> Library... -> Java and choose your LWJGL3 global library, if you haven't made that before do the following steps
    1. Click on the green + -> Library... -> Java, then go to your folder where you extracted lwjgl.zip and go in the jar folder and select lwjgl.jar and disruptor.jar
    2. Click on the green +, then go to your folder where you extracted lwjgl.zip and select src.zip
    3. Click on the green +, then go again to the folder where you extracted lwjgl.zip and go into the doc folder and select javadoc.zip
    4. Set the Level to Global Library so you can add the library in a new project faster
  6. Now in your main menu select Run -> Edit Configurations
  7. Click on the green + and select Application
  8. Click into Main class and type the path to your main class
  9. Click into VM options and type -Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native/<os>/<arch>" where <os> is either windows, linux or macosx and <arch> is either x86 or x64, depending on your system.
    Note that you could also just use -Dorg.lwjgl.librarypath="<path to the extracted lwjgl.zip>/native and LWJGL3 will choose the right path for you.

Test your setup

After setting up your IDE just copy and paste this code, then run it. If it runs successfully then your setup is complete.
If you get Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to load the native library: lwjgl you have not set the org.lwjgl.librarypath correctly. This is the most important part when setting up your project, so make sure you have set the native path according to your system.

package test.setup;

import org.lwjgl.Sys;

public class TestSetup {

    public static void main(String[] args) {
        System.out.println("LWJGL Version " + Sys.getVersion() + " is working.");
    }
}

After setting up the library and your IDE it is time to get started.

Clone this wiki locally