Skip to content

leaningtech/cheerpj-natives

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

cheerpj-natives

Discord server

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.

Usage

  1. Download cheerpj-natives and place the cheerpj-natives folder at the root of your web server.
  2. Pass the following property to the cheerpjInit options: javaProperties: ["java.library.path=/app/cheerpj-natives/natives"]

LWJGL

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

  1. Add this HTML to the start of the document body:
<canvas id="lwjgl" width="800" height"600"></canvas>
  1. In your script, add the following line before the cheerpjRunMain or cheerpjRunJar call:
window.lwjglCanvasElement = document.getElementById("lwjgl");

Example

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>

About

JS implementations of JNI libraries for CheerpJ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published