Start

Getting started

Add Jolt to a Maven or Gradle project and open your first native window with a web page, in plain Java.

Jolt opens a native window whose contents are a web page, and lets that page talk to Java in the same process. It uses the web view the operating system already has, so there is no bundled browser and no native code to compile.

Requirements

  • JDK 25 and Maven 3.9 or newer (Gradle works too).
  • Windows 10 or 11 with the WebView2 Runtime (preinstalled on Windows 11).
  • Linux (X11 or Wayland) with GTK 3 and WebKitGTK 4.1: sudo apt install libgtk-3-0 libwebkit2gtk-4.1-0.

Add Jolt to your project

Add the API and both backends. Each backend only activates on its own operating system, so one jar runs on both.

<properties>
  <maven.compiler.release>25</maven.compiler.release>
  <jolt.version>0.3.1</jolt.version>
</properties>

<dependencies>
  <dependency>
    <groupId>io.github.b077as</groupId>
    <artifactId>jolt-core</artifactId>
    <version>${jolt.version}</version>
  </dependency>
  <dependency>
    <groupId>io.github.b077as</groupId>
    <artifactId>jolt-win32</artifactId>
    <version>${jolt.version}</version>
  </dependency>
  <dependency>
    <groupId>io.github.b077as</groupId>
    <artifactId>jolt-linux</artifactId>
    <version>${jolt.version}</version>
  </dependency>
</dependencies>

Gradle:

implementation("io.github.b077as:jolt-core:0.3.1")
implementation("io.github.b077as:jolt-win32:0.3.1")
implementation("io.github.b077as:jolt-linux:0.3.1")

Run Java with --enable-native-access=ALL-UNNAMED, or put Enable-Native-Access: ALL-UNNAMED in your jar manifest (maven-jar-plugin, manifestEntries). Otherwise Java prints a warning on every start.

Your first window

Application app = Application.create(AppOptions.of("com.example.hello"));
try {
    app.run(() -> {
        WebWindow window = app.createWindow(WindowOptions.defaults().withTitle("Hello").withSize(600, 400));
        window.onMessage(text -> window.postMessage("Java received: " + text));
        window.loadHtml("""
                <button onclick="jolt.postMessage('ping')">Ping Java</button>
                <p id="out"></p>
                <script>jolt.onMessage(m => document.getElementById('out').textContent = m)</script>
                """);
    });
} finally {
    app.close();
}
  • AppOptions.of(id) names your app and picks a per-user data folder (%LOCALAPPDATA%\<id> or ~/.local/share/<id>).
  • app.run(onStart) blocks until the app ends: the last window closed, or quit(). Create windows inside onStart.
  • window.jolt is injected into every page: jolt.postMessage(text) sends to Java, jolt.onMessage(cb) receives.
  • To end the app, let main return rather than calling System.exit.

See a complete app

Parsel is a full desktop mail client built on Jolt, and its source is open: Java for IMAP and SMTP, a Vue page for the interface, one process. It is the reference for how a real Jolt app is put together, from the messaging layer to packaging.

Parsel on GitHub

Next: messaging between Java and the page.