A collection of alternative implementations of native libraries to be used when running Java applications with CheerpJ.
Currently only a partial implementation of LWJGL is included.
- Download cheerpj-natives and place the
cheerpj-natives
folder at the root of your web server. - Pass the following property to the
cheerpjInit
options:javaProperties: ["java.library.path=/app/cheerpj-natives/natives"]
The LWJGL implementation requires that you provide a canvas for it to render to by setting window.lwjglCanvasElement
. If you don't do this, you'll see the following error:
Error: window.lwjglCanvasElement is not set or is not a canvas
- Add this HTML to the start of the document body:
<canvas id="lwjgl" width="800" height"600"></canvas>
- In your script, add the following line before the
cheerpjRunMain
orcheerpjRunJar
call:
window.lwjglCanvasElement = document.getElementById("lwjgl");
Following from the getting started tutorial:
<canvas id="lwjgl"></canvas>
<script type="module">
await cheerpjInit({
javaProperties: ["java.library.path=/app/cheerpj-natives/natives"],
});
cheerpjCreateDisplay(800, 600);
window.lwjglCanvasElement = document.getElementById("lwjgl");
await cheerpjRunJar("/app/CHANGEME.jar");
</script>