{"id":21844052,"url":"https://github.com/electronstudio/jaylib","last_synced_at":"2025-04-04T22:02:57.560Z","repository":{"id":43804952,"uuid":"252593967","full_name":"electronstudio/jaylib","owner":"electronstudio","description":"Java JNI bindings for Raylib","archived":false,"fork":false,"pushed_at":"2024-12-31T18:14:02.000Z","size":20097,"stargazers_count":153,"open_issues_count":14,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T21:02:48.850Z","etag":null,"topics":["java","jaylib","jni","raylib"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/electronstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-03T00:20:20.000Z","updated_at":"2025-03-28T13:20:08.000Z","dependencies_parsed_at":"2024-10-27T21:13:55.330Z","dependency_job_id":"fb9e9cc1-0682-448f-b186-e40d57263d57","html_url":"https://github.com/electronstudio/jaylib","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fjaylib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fjaylib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fjaylib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electronstudio%2Fjaylib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electronstudio","download_url":"https://codeload.github.com/electronstudio/jaylib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256104,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","jaylib","jni","raylib"],"created_at":"2024-11-27T22:18:18.849Z","updated_at":"2025-04-04T22:02:57.539Z","avatar_url":"https://github.com/electronstudio.png","language":"C","readme":"# News\n\n* Take a look at [Jaylib-FFM](https://github.com/electronstudio/jaylib-ffm) a Java FFM Raylib binding.\n\n* The `com.raylib.Jaylib` class has been removed because it seemed to confuse people and IDE\nautocompletion.  Use `com.raylib.Raylib` instead.  The Colors are now in `com.raylib.Colors`.\nIf you don't like the fluent constructor syntax of JavaCPP, use the methods in `com.raylib.Helpers`\nto create structs.\n\n# Jaylib - JNI bindings for [Raylib](https://github.com/raysan5/raylib/) 5.5 + RLGL + Raymath + Physac + RayGui\n\nJNI is the fastest kind of native binding for Java 8+, but is difficult to write.  Therefore\nwe are using [JavaCPP](https://github.com/bytedeco/javacpp) to automatically generate the bindings.\nThe results are not quite as Java-like\nas you would get from a hand-written binding, but they are not bad, and should be easy to keep up to date\nwith the latest changes in Raylib.\n\nJavaCPP is very mature and powerful but not hugely documented, so it is probably capable of doing more than we are\ndoing so far.\nSee [issues](https://github.com/electronstudio/jaylib/issues).\n\nIf there is a newer version of Raylib out then you can probably re-generate these bindings with little or no changes, because\nthey are auto-generated.  See [How To Build](#how-to-build)\n\n## Platforms\n\n5.5+ release includes binaries for:\n* Windows x86_64\n* Macos x86_64\n* Macos ARM64\n* Linux x86_64\n* Linux ARM64 (Raspberry Pi Bullseye, 64 bit only, untested)\n\n## Docs\n\n[Javadocs are here](http://electronstudio.github.io/jaylib) but you will also need to refer to\n[raylib.h](https://github.com/raysan5/raylib/blob/master/src/raylib.h) and Raylib's [cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)\nand [examples](https://www.raylib.com/examples.html) to learn Raylib.\n\n## Example project\n\nDownload [the Gradle example project](https://github.com/electronstudio/jaylib-example-project) and import it into IntelliJ or Eclipse to get up and running immediately.\n\n([Maven example](https://github.com/electronstudio/jaylib-maven-example-project))\n\n## Video tutorials\n\n[Getting started with IntelliJ](https://www.youtube.com/watch?v=_xuFjU7YZ4s)\n\n[Getting started with Eclipse](https://www.youtube.com/watch?v=3DrCWtDTI6o)\n\n## How to use with Gradle\n\n```\n\ndependencies {\n    implementation 'uk.co.electronstudio.jaylib:jaylib:5.5.+'\n}\n\n```\n\n## How to use with Maven\n\n```\n\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003euk.co.electronstudio.jaylib\u003c/groupId\u003e\n            \u003cartifactId\u003ejaylib\u003c/artifactId\u003e\n            \u003cversion\u003e[5.5.0,5.6)\u003c/version\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\n```\n\n## How to use from command line\n\nDownload the latest `jaylib.jar` from [releases](https://github.com/electronstudio/jaylib/releases)\n\nWrite a demo program, e.g. Demo.java\n\n```java\nimport static com.raylib.Colors.*;\nimport static com.raylib.Raylib.*;\n\npublic class Demo {\n    public static void main(String args[]) {\n        InitWindow(800, 450, \"Demo\");\n        SetTargetFPS(60);\n        Camera3D camera = new Camera3D()\n                ._position(new Vector3().x(18).y(16).z(18))\n                .target(new Vector3())\n                .up(new Vector3().x(0).y(1).z(0))\n                .fovy(45).projection(CAMERA_PERSPECTIVE);\n        // Add this line only if Raylib version \u003c 4.5:\n        // SetCameraMode(camera, CAMERA_ORBITAL);\n\n        while (!WindowShouldClose()) {\n            UpdateCamera(camera, CAMERA_ORBITAL);\n            BeginDrawing();\n            ClearBackground(RAYWHITE);\n            BeginMode3D(camera);\n            DrawGrid(20, 1.0f);\n            EndMode3D();\n            DrawText(\"Hello world\", 190, 200, 20, VIOLET);\n            DrawFPS(20, 20);\n            EndDrawing();\n        }\n        CloseWindow();\n    }\n}\n```\n\nCompile it:\n\n    javac -cp jaylib-5.5.0-2.jar Demo.java\n    \nRun it:\n\n    java -cp jaylib-5.5.0-2.jar:. Demo\n    \nOn MacOS you need this additional option:\n\n    java -XstartOnFirstThread -cp jaylib-5.5.0-2.jar:. Demo\n    \nOn weirdy Windows you use semi-colons:\n\n    java -cp jaylib-5.5.0-2.jar;. Demo\n\n## Known issues\n\n### Getters and setters\n\nJavaCPP does not use the 'get' and 'set' names in the methods (nor does it expose public fields).  To access a field:\n\n    var x = vector.x()\n\nTo set a field:\n    \n    vector.x(3)\n\nRemember each time you do either of those you are accessing native memory.\n\n### Position field\n\nJavaCPP has a field of its own called `position` so it renames the actual position field to `_position`.\n\n### Constructors\n\nJavaCPP does not generate constructors.  The recommended JavaCPP way to initialize a struct is like this:\n\n     var vec = new Vector3().x(1).y(2).z(3);\n\nSome people do not like this.  You can use helper functions, e.g. `com.raylib.Helpers.createVector3(1,2,3)`. For discussion [see here](https://github.com/electronstudio/jaylib/issues/1#issuecomment-873485303).\n\n### Arrays\n\nArrays of C objects are not Java arrays.  For example, a `model` has an array of `materials` each\nof which have an arrays of `maps`.  To access the second map of the first material:\n\n    model.materials().position(1).maps().position(2)\n\n\n## How to build\n\n### Linux and Mac\n\nClone this repo including submodules so you get correct version of Raylib.\n\ngit clone --recurse-submodules  https://github.com/electronstudio/jaylib\n\nWe have automated builds on Github Actions.  To build manually, follow the steps in the [build file](https://github.com/electronstudio/jaylib/blob/master/.github/workflows/build.yml)\n\n### Windows\n\nOpen a Visual C 2019 native x64 command prompt *with admin permissions* so that symlinks work.\n\nClone this repo including submodules so you get correct version of Raylib.  (On Windows, Google for how to enable symlinks\n)\n\n    git clone --recurse-submodules  -c core.symlinks=true https://github.com/electronstudio/jaylib\n\nBuild and install Raylib from the `raylib` directory.\n\n    cd jaylib/raylib\n    mkdir build\n    cd build\n    cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release ..\n    msbuild raylib.sln /target:raylib /property:Configuration=Release\n    copy raylib\\Release\\raylib.lib ..\\..\n    cd ..\\..\n\nBuild just the jaylib-natives.jar:\n\n    set RAYLIB_VERSION=4.0.0\n    set RAYLIB_PLATFORM=windows-x86_64\n    build-windows.bat\n\nTo build everything including the jaylib.jar you will need git-bash installed.\nEdit `build-windows.sh`.  Change `LINK_PATH` to the full path to the `jaylib` folder.\n(Yes, you would think JavaCPP could work this out for itself, or that relative paths could be used, but it seems not to work on Windows.)\n\n    build-windows.sh\n\n\n## License\n\nJaylib is distributed under the GPL license with the Classpath Exception to allow linking, the same as OpenJDK itself, so you can use it\nanywhere that you use the JDK, for both free and non-free ('closed source') projects.\n\n\n## Performance\n\nEvery call to C is costly, so it's slightly faster if you use Java data structures and functions when calculating\nin your update loop\nand then only convert them to native C data structures when you have to call the C functions for drawing.\n\n### Bunnymark\n\n| Library                                                     | Implementation                                                                  | Bunnies (60 FPS) | Percentage |\n|-------------------------------------------------------------|---------------------------------------------------------------------------------|-----------------|------------|\n| Raylib 5.0                                                  | C                                                                               | 180000          | 100%       |\n| [Raylib-J](https://github.com/CreedVI/Raylib-J/) v0.2-alpha | Java 17                                                                         | 151000          | 84%        |\n| [Raylib-J](https://github.com/CreedVI/Raylib-J/) v0.5       | Java 22                                                                         | 146000          | 81%        |\n| Foreign Function and Memory API                             | Java 22                                                                         | 150000          | 83%        |\n| Jaylib 5.0 *                                                | Java 22                                                                         | 118000          | 65%        |\n| Jaylib 3.7 *                                                | Java 17                                                                         | 73000           | 41%        |\n| Jaylib 3.7 *                                                | Java 11                                                                         | 64000           | 36%        |\n| Jaylib 3.7 *                                                | Java 11 GraalVM 21.2                                                            | 64000           | 36%        |\n| Jaylib 3.7                                                  | Java 11                                                                         | 39000           | 22%        |\n| Jaylib 3.7 *                                                | [GraalVM 21.2 native image](https://github.com/electronstudio/jaylib/issues/26) | 39000           | 22%        |\n| [Kaylib](https://github.com/electronstudio/kaylib) 3.7      | Kotlin native                                                                   | 28000           | 16%        |\n\n*I'm using a version of Bunnymark that avoids the most egregious native calls here.\n\n## See also\n\n[LibRLImg](https://codeberg.org/glowiak/librlimg) - load Textures and Images from jarfile resources\n\n[Megabunny](https://github.com/electronstudio/megabunny) - Raylib benchmarks\n\n[Jaylib-FFM](https://github.com/electronstudio/jaylib-ffm) - Java FFM Raylib binding\n\n[jlImGui](https://github.com/violent-studio/jlImGui) - ImGui binding for Jaylib\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectronstudio%2Fjaylib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felectronstudio%2Fjaylib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectronstudio%2Fjaylib/lists"}