List icon Contents

Chromium

This guide describes how to work with the Chromium build used by JxBrowser.

You do not need to install Chromium or Google Chrome on the target environment to use JxBrowser. JxBrowser uses and deploys its own Chromium build.

Binaries

Chromium binaries for each supported platform are located inside correspondent JxBrowser JARs:

  • jxbrowser-win32-7.41.3.jar – Chromium binaries for Windows 32-bit.
  • jxbrowser-win64-7.41.3.jar – Chromium binaries for Windows 64-bit.
  • jxbrowser-mac-7.41.3.jar – Chromium binaries for macOS.
  • jxbrowser-mac-arm-7.41.3.jar – Chromium binaries for macOS Apple Silicon.
  • jxbrowser-linux64-7.41.3.jar – Chromium binaries for Linux 64-bit.
  • jxbrowser-linux64-arm-7.41.3.jar – Chromium binaries for Linux ARM 64-bit.

Location

By default, JxBrowser extracts Chromium binaries to the user’s temp directory on Linux and macOS, and to AppData\Local\JxBrowser directory on Windows.

Here is how to change the directory where JxBrowser will extract the binaries:

  1. Using the jxbrowser.chromium.dir system property.

    It can be done either by System.setProperty() method:

    Java
    Kotlin
    System.setProperty("jxbrowser.chromium.dir", "Users/Me/.jxbrowser");
    
    System.setProperty("jxbrowser.chromium.dir", "Users/Me/.jxbrowser")
    

    or through a JVM parameter:

    -Djxbrowser.chromium.dir="Users/Me/.jxbrowser"
    
  2. Via the EngineOptions when constructing the Engine:

    Java
    Kotlin
    Engine engine = Engine.newInstance(EngineOptions.newBuilder(renderingMode)
            .chromiumDir(Paths.get("Users/Me/.jxbrowser"))
            .build());
    
    val engine = Engine.newInstance(EngineOptions.newBuilder(renderingMode)
        .chromiumDir(Path("Users/Me/.jxbrowser"))
        .build())
    

The directory path can be either relative or absolute.

The directory cannot be located on a network drive.

Verification

Each JxBrowser version is compatible only with the same version of the binaries. For example, JxBrowser 7.41.3.1 will not work with the binaries from JxBrowser 7.41.3.

To make sure that the Chromium binaries are compatible with the current JxBrowser version, the library verifies the binaries.

Extraction

By default, JxBrowser extracts binaries from a corresponding JAR file when Engine is first created. If you need to extract binaries earlier, use this code:

Java
Kotlin
// Use the default directory.
ChromiumBinaries.deliverToDefaultDirectory();
// Or use an arbitrary directory.
ChromiumBinaries.deliverTo(Paths.get("/path/to/binaries"));
// Use the default directory.
ChromiumBinaries.deliverToDefaultDirectory()
// Or use an arbitrary directory.
ChromiumBinaries.deliverTo(Path("/path/to/binaries"))

If the compatible binaries are already extracted, JxBrowser will not extract them again. Otherwise, JxBrowser will extract the binaries again and override the existing files.

Custom delivery

Starting with JxBrowser 7.35, developers can get the full control of delivering Chromium binaries to the environment. This capability is intended for advanced use cases, such as downloading binaries from the network, or using a custom compression algorithm.

To customize the delivery, implement BinariesDelivery interface and deliver the binaries when you need them:

Java
Kotlin
class TuneBinaryDelivery implements BinariesDelivery {

    public void deliverTo(Path chromiumDir) {
        // Pseudocode:
        // Path downloadedArchive = SharedNetworkDrive.download("jxbrowser-win64.gz");
        // Gzip.extract(downloadedArchive, chromiumDir);
    }
}
...
// Use the default directory.
ChromiumBinaries.deliverToDefaultDirectory(new TuneBinaryDelivery());

// Or use an arbitrary directory.
ChromiumBinaries.deliverTo(chromiumDir, new TuneBinaryDelivery());
class TuneBinaryDelivery : BinariesDelivery {
    override fun deliverTo(chromiumDir: Path) {
        // Pseudocode:
        // Path downloadedArchive = SharedNetworkDrive.download("jxbrowser-win64.gz");
        // Gzip.extract(downloadedArchive, chromiumDir);
    }
}
...
// Use the default directory.
ChromiumBinaries.deliverToDefaultDirectory(TuneBinaryDelivery())

// Or use an arbitrary directory.
ChromiumBinaries.deliverTo(chromiumDir, TuneBinaryDelivery())

If the compatible binaries are already extracted, JxBrowser will not call the custom delivery.

Sandbox

Windows

JxBrowser supports Chromium Sandbox on Windows. Sandbox is enabled by default, but you can disable it via the appropriate Engine option:

Java
Kotlin
Engine engine = Engine.newInstance(EngineOptions.newBuilder(renderingMode)
        .disableSandbox()
        .build());
val engine = Engine.newInstance(EngineOptions.newBuilder(renderingMode)
    .disableSandbox()
    .build())

Linux and macOS

Currently, Sandbox is supported on Windows platform only.