Load a Java Library
- classPath (
string) - The path to the library’s jar file in the virtual filesystem. Pass an empty string to load the standard library only.
cheerpjRunLibrary returns a Promise which resolves to a
This object can be used to access the classes and methods of the loaded library through property access:
- To load a class, access it and await it.
- To call a static method, call it as a method on a loaded class and await it.
- To construct a class into an instance, use
- To call an instance method, call it as a method on an instance of a loaded class and await it.
Array interoperability is supported:
- Passing JS arrays to Java arrays via copying.
- Passing JS arrays to Java JSObject.
- Public Java fields can now be both read/written from JS with appropriate type conversion.
- Classes in JS supports
Using the standard library
Using a custom library
Let’s say we had a library called
example.jar compiled from the following class:
example.jar being available on the web server at
/example.jar, we could use it like so:
Access to object property/attribute
From the example above: