This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Jaylib is a Java Native Interface (JNI) binding library for Raylib 5.5, providing Java developers with access to the popular C game development library. The project uses JavaCPP to automatically generate JNI bindings from the native Raylib headers.
./build-java.sh- Main Java compilation and JAR creation (requiresRAYLIB_VERSIONenvironment variable)./build-linux.sh- Linux platform-specific build./build-windows.sh- Windows platform build (requires Visual Studio environment)./build-native.sh- Native library compilation
./run-test.sh- Run the basic functionality test (requiresRAYLIB_PLATFORMenvironment variable)./run-test-jar.sh- Run tests using the compiled JAR
./build-docs.sh- Generate Javadoc documentation
RAYLIB_VERSION- Version string for builds (e.g., "5.5.0-0")RAYLIB_PLATFORM- Platform identifier (e.g., "linux-x86_64", "windows-x86_64", "macosx-x86_64")
- JavaCPP Integration: Uses
javacpp.jarand JavaCPP annotations inRaylibConfig.javato automatically generate JNI bindings - Multi-stage Build Process:
- Generate Java bindings from C headers using JavaCPP
- Compile native code with platform-specific linkers
- Package everything into distributable JARs
src/com/raylib/RaylibConfig.java- JavaCPP configuration defining platform-specific linking and header includessrc/com/raylib/Raylib.java- Auto-generated main binding class (created during build)src/com/raylib/Colors.java- Predefined color constants (RAYWHITE, BLACK, etc.)src/com/raylib/Helpers.java- Alternative constructor methods for structssrc/com/raylib/Test.java- Basic functionality test and demo
The project includes Raylib C header files:
raylib.h- Core Raylib APIrlgl.h- OpenGL abstraction layerraymath.h- Math utility functionsphysac.h- Physics simulationraygui.h- Immediate mode GUI
Configured for cross-platform builds supporting:
- Windows x86_64
- macOS x86_64 and ARM64
- Linux x86_64 and ARM64
- Getters:
vector.x()returns the x field value - Setters:
vector.x(3)sets the x field to 3 - Position field renamed to
_positiondue to JavaCPP's internal position field
JavaCPP uses fluent constructor syntax:
var vec = new Vector3().x(1).y(2).z(3);Alternative constructors available in Helpers.java:
var vec = Helpers.createVector3(1, 2, 3);C arrays are not Java arrays - use position() method:
model.materials().position(1).maps().position(2) // Second map of first material- Java 8+ (JDK required for compilation)
- Platform-specific C++ compiler (GCC on Linux, Visual Studio on Windows, Xcode on macOS)
- JavaCPP tool (included as
javacpp.jar) - Raylib native library (included as git submodule)
When running Java applications on macOS, use the -XstartOnFirstThread JVM option:
java -XstartOnFirstThread -cp jaylib.jar:. MyGame