LWJGL is organized in modules. Each module is packaged as a collection of artifacts, where each artifact has the same name but a different classifier.
- The artifact name for the LWJGL core module is just
- The artifact name for a binding module is
lwjgl-<binding>, for example
lwjgl-openglfor the OpenGL module.
The artifacts based on classifier are:
- No classifier: the compiled Java classes
sources: the Java sources
javadoc: the API documentation
natives-<platform>: the native shared libraries for the corresponding platform
Not all artifacts have natives and not all artifacts with natives are available on all platforms.
This design means that you only need to download the modules that are needed for your project.
Additional modules can be downloaded and added later on, if your needs change.
Downloading LWJGL - Using the build configurator
The LWJGL website provides a handy configurator for choosing which parts of the library you want to download. This section will contain a brief explanation of what the separate parts of this configurator do.
There are three separate release channels to choose from: Release, Stable and Nightly. Unless you know what you are doing, you should use Release, as it will be more stable.
The Mode selector allows you to choose how you want to download the library. If you plan on
using an IDE or need the actual
.jar files, choose ZIP Bundle. If you are going to use maven
or gradle, choose the respective option to generate a build script.
Maven/Gradle is recommended during development. The zip bundle is recommended when creating a production build or installer for your application.
Natives are not required for compiling your project, but are needed for running it. Thus, you need to get natives for all the platforms you want to run your application on. Remember that you don't need to download natives for all platforms at once. You can download additional natives when you are ready to distribute your project.
If it is your first time using LWJGL, the Getting Started or Minimal OpenGL presets should be sufficient to get started with most tutorials. Alternatively, you can create a custom configuration and choose exactly which modules you want. Keep in mind that you can view the description of the different modules by ticking Show descriptions under Settings.
Extracting the natives (optional)
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.
SharedLibraryLoaderextracts the natives once and reuses them from run to run. The natives are overridden only if a different LWJGL version is detected.
The extract directory can be customized with
SharedLibraryLoader is optional. For example a custom installer for an application may
extract the natives to a specific location. In such cases, the familiar options
Configuration.LIBRARY_PATH) are still
Setting up your build tool or IDE
Gradle or maven
When using either gradle or maven you can simply copy the build script generated by the generator
and use it to build your project. Note that when using gradle you probably want to prepend
apply plugin: 'java' and
apply plugin: 'application' to
IDEA supports Gradle/Maven projects and makes it trivial to use them. For a custom configuration, follow these instructions:
- Go to our download page, select channel, select zip bundle, review the options and choose the bindings you're interested in, then click on Generate Bundle.
- When the download is complete, extract its contents in your project.
- In IntelliJ, go to Project Structure > Libraries > New Project Library. Add all LWJGL
.jarfiles (classes+natives) to the library and add the library as a dependency to your project module(s). You do not need to extract the native libraries.
- If you also downloaded the sources, add the corresponding
.jarfiles as sources to the LWJGL library. You do not need to download and attach the javadoc
.jarfiles, IntelliJ generates javadoc directly from sources.
If you want to match the Maven/Gradle behavior exactly, you could create 2 separate libraries:
- One with the class+source
.jarfiles, make it a compile dependency of your module(s).
- One with the natives
.jarfiles, make it a runtime dependency of your module(s).
You can do this in the Project Structure > Modules > select a module > Dependencies tab, by changing the Scope of each dependency.
- Download LWJGL as a ZIP Bundle using the build configurator and extract the archive to somewhere you will be able to find it later.
- Inside Netbeans, under Tools > Libraries press New Library... in the bottom left corner.
- Name the library something sensible, such as "LWJGL 3.1.0" and press OK
- The center of the Library window should now contain options to configure the library.
- In the Classpath tab add all
.jarfiles from the previously downloaded
.zipfile, excluding those containing sources or javadoc in their name
- (Optional) In the Sources tab add all
.jarfiles with sources in their name. This will give you access to both documentation and the source code directly from NetBeans. Source can be viewed in the editor with Ctrl-Left click while hovering over a function or class that belongs to LWJGL.
- Create a new project by choosing File > New Project.... Choose Java | Java Application as the project type.
- Find your project in the project window (Can be opened with Ctrl-1). Right click on Libraries, choose Import, find the previously created library and select Import Library and then Add Library.
- Check if everything worked as intended by adding the following line to your main class and
running the project:
System.out.println(org.lwjgl.Version.getVersion());. This should print the version of LWJGL which you are using.
(you need at least Eclipse Luna (4.4) or Eclipse Kepler (4.3) with the "Eclipse Java 8 Support (for Kepler SR2)" patch installed to work with LWJGL 3 in Eclipse)
Eclipse supports Gradle/Maven projects and it is highly recommended to use them instead of a manual Eclipse project configuration. However, if you prefer setting up a native Eclipse project, follow these instructions (works with Eclipse Neon):
- Download the ZIP bundle from https://www.lwjgl.org/customize
- When the download is complete, extract its contents to some file system directory, henceforth referred to as
- In Eclipse go to menu "Window" > "Preferences" and in the tree view to the left search for 'Java' > 'Build Path' > 'User Libraries'
- Click "New..." in the 'User Libraries' dialog. In the opened modal dialog "New User Library" write "LWJGL3" in the 'User library name:' text field and click 'OK'. The newly created library "LWJGL3" should show up in the list 'Defined user libraries:'.
- Now, select this item in the list and click 'Add External JARs...'. This opens a standard OS file selection dialog allowing you to select
*.jarfiles which get added to the classpath/buildpath of all projects using the LWJGL3 User Library. Go to
<lwjgl3>and select all
*.jarfiles which do not have
-sourcesin their names. Make sure you don't forget the
lwjgl-natives-<os>.jarfile, and click 'Open'.
- This will populate the LWJGL3 user library in the list with respective entries for all selected jar files. You could leave it at that now in order to use LWJGL 3.
- However, if you want to have Sources and JavaDocs, you will have to select each of the entries, click on 'Source attachment: (None)' and on 'Edit...'. This will open the "Source Attachment Configuration" dialog. Here you could select 'External location' and 'External File...' to select the appropriate
- In order to actually use the LWJGL3 User Library in one of your projects, go to the Build Path settings of your project and select the 'Libraries' tab. Here, click 'Add Library...', select 'User Library' and mark the "LWJGL3" User Library.
- Now you are set up to use LWJGL 3 in your project.
If you are familiar with other tools or IDEs, feel free to add information about setting up LWJGL in them to this section. If you want to contribute, please make a post on the forum.