Skip to content

JJBridge Api implementation using V8 JavaScript engine.

License

Notifications You must be signed in to change notification settings

Forge-Srl/jjbridge-engine-v8

Repository files navigation

JJBridge V8 Engine

javadoc

Build JJBridge V8 Engine for Android

Build JJBridge V8 Engine for Linux

Build JJBridge V8 Engine for macOS

Build JJBridge V8 Engine for Windows

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.

Contents

Installation

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>

Usage

The full javadoc is available at https://www.javadoc.io/doc/srl.forge/jjbridge-engine-v8/latest/index.html.

Initialization

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) {
}

Technical details

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)

License

See the LICENSE file for license rights and limitations (MIT).