LWJGL 3 uses an Ant-based build system and a Kotlin-powered code generator. Before you write any code, you need a working JDK, Ant, and a clone of the repository. This page walks through every step from cloning to running your first demo.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/LWJGL/lwjgl3/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- JDK 8 or newer — LWJGL 3 requires Java 8 to build and run.
- Ant 1.9.3 or newer — All build targets are defined as Ant tasks.
Cloning and initializing
ant init downloads Kotlin, TestNG, JCommander, and other compile-time dependencies into bin/libs/. You only need to run it once. If you also intend to work on the wiki, run ant init-wiki as well (optional).
Build process
The build pipeline runs in this order. Each step depends on the previous one completing successfully.Compile the Generator and Templates
Run the Generator
modules/lwjgl/*/src/templates/kotlin/. The Generator compares input and output timestamps and only writes files that have changed, keeping native recompilation to a minimum.Compile native code
LWJGL_BUILD_ARCH environment variable (see below).If incremental generation causes unexpected results, use the
ant clean-* targets to force a clean rebuild of the affected module.IDE setup
- IntelliJ IDEA
- Eclipse
- NetBeans
LWJGL ships a pre-configured IntelliJ IDEA project. The free Community Edition works with the Kotlin and Ant plugins. The TestNG and Copyright plugins are optional.
- Open File > Open and select the root folder of the cloned repository.
- Open File > Project Structure > Project and choose or create the Project SDK.
- If you skipped
ant init-wiki, either ignore the VCS root errors or remove the missing directories under Settings > Version Control.
Build configuration
The Ant build reads the following optional environment variables.| Variable | Description |
|---|---|
LWJGL_BUILD_TYPE | Source of pre-built binary dependencies. Valid values: nightly (default — latest CI build), stable (latest verified nightly), release/latest (latest official release), release/{version} (a specific release). |
LWJGL_BUILD_ARCH | Target native architecture. One of x64, x86, arm64, or arm32. Defaults to the architecture of the JVM running Ant. Set this to cross-compile. |
LWJGL_BUILD_OFFLINE | Set to true, on, or yes to prevent Ant from downloading binary dependencies. Useful when working offline or when using custom native builds. |
LWJGL_BUILD_OUTPUT | Override the default output root. By default, /bin, /generated, and /release are created in the repository root. When this variable is set, those directories become symlinks pointing into the specified path — useful for faster storage. |
Runtime configuration
LWJGL properties are read at runtime from system properties or set programmatically via theConfiguration class. There are two property types:
- STATIC — Read once during class initialization and stored in
static finalvariables. These must be set before any LWJGL class is loaded. - DYNAMIC — May be read repeatedly; they can change LWJGL behavior at any point during execution.
Configuration class. Useful options for development include:
| Property | Type | Effect |
|---|---|---|
org.lwjgl.util.Debug | Static | Enables debug mode; prints info messages and activates extra runtime checks. |
org.lwjgl.util.DebugAllocator | Static | Tracks every memAlloc/memFree call and reports leaks on JVM exit. |
org.lwjgl.util.DebugStack | Static | Reports asymmetric MemoryStack push/pop pairs immediately. |
org.lwjgl.util.DebugLoader | Static | Prints SharedLibraryLoader exceptions (requires Debug). |
org.lwjgl.librarypath | Dynamic | One or more directories (separated by File.pathSeparator) that take priority over java.library.path when loading natives. |
The Generator
The Generator translates Kotlin template files into Java binding classes and C JNI glue code. Both the Generator itself and all binding templates are written in Kotlin.- Generator source:
modules/generator/src/main/kotlin/org/lwjgl/generator - Template configuration:
modules/lwjgl/<module>/src/templates/kotlin/<module> - Template source:
modules/lwjgl/<module>/src/templates/kotlin/<module>/templates