JJBridge is a multi-library project which brings JavaScript execution capabilities to Java.
JJBridge V8 Engine allows using V8 as the underlying engine for JJBridge Api.
V8 binaries shipped with JJBridge V8 Engine are platform dependent. To keep the packages small (and to avoid loading the wrong libraries), we distribute a jar with a different classifier for each platform. Here is how you add it based on your target platform:
- For Linux add this to your pom.xml:
<dependency> <groupId>srl.forge</groupId> <artifactId>jjbridge-engine-v8</artifactId> <classifier>linux</classifier> </dependency>
- For macOS add this to your pom.xml:
<dependency> <groupId>srl.forge</groupId> <artifactId>jjbridge-engine-v8</artifactId> <classifier>macos</classifier> </dependency>
- For Windows add this to your pom.xml:
<dependency> <groupId>srl.forge</groupId> <artifactId>jjbridge-engine-v8</artifactId> <classifier>windows</classifier> </dependency>
- For Android add this to your pom.xml:
<dependency> <groupId>srl.forge</groupId> <artifactId>jjbridge-engine-v8</artifactId> <classifier>android</classifier> <type>aar</type> </dependency>
The full javadoc is available at https://www.javadoc.io/doc/srl.forge/jjbridge-engine-v8/latest/index.html.
To get a JSEngine
just use:
JSEngine engine = new V8Engine();
You can also pass flags to V8 by calling V8Engine.setFlags()
before instantiating V8Engine
.
Then instantiate a JSRuntime
and use JJBridge as usual:
try (JSRuntime runtime = engine.newRuntime()) {
// Do JavaScript things here...
} catch (RuntimeException e) {
}
JJBridge V8 Engine currently uses V8 version 9.1.269.36. V8 precompiled binaries are taken from https://github.com/tbossi/v8-builder thus the following platforms are supported:
- Linux (x64)
- Android (x86, x86-64, arm v7, arm v8)
- macOS (x64)
- Windows (x64)
See the LICENSE file for license rights and limitations (MIT).