List icon Contents

Posted on October 7, 2024

JxBrowser 8.0.0

We are excited to announce the release of JxBrowser 8.0.0!

This new major version introduces a number of new features and improvements, including Kotlin DSL, Compose Desktop support, Chrome extensions, Windows ARM64 support, touch input, custom DOM events, and more. JxBrowser now requires Java 17 or later.

We did not change the API significantly, so you can easily migrate your existing code to the new version. However, we recommend that you review the migration guide to learn about the changes and improvements in JxBrowser 8.0.0.

More information about the new features and improvements in JxBrowser 8.0.0 can be found below.

Kotlin DSL

You can write more concise and readable Kotlin code when working with JxBrowser API thanks to the Kotlin DSL. To add the Kotlin DSL to your project, add the following dependency to your project configuration:

Gradle
Maven
dependencies {
    // Adds a dependency to the Kotlin DSL for working with JxBrowser API.
    implementation(jxbrowser.kotlin)
}
<!-- Adds a dependency to the Kotlin DSL for working with JxBrowser API. -->
<dependency>
    <groupId>com.teamdev.jxbrowser</groupId>
    <artifactId>jxbrowser-kotlin</artifactId>
    <version>8.0.0</version>
</dependency>

Here is an example of how you can use the Kotlin DSL to create and configure an Engine instance:

Kotlin
val engine = Engine(RenderingMode.HARDWARE_ACCELERATED) {
    options {
        license = JxBrowserLicense("your_license_key")
        language = Language.GERMAN
        remoteDebuggingPort = 9222
        schemes {
            add(Scheme.JAR, InterceptJarRequestCallback())
        }
    }
}
val browser = engine.newBrowser()

Compose Desktop

We added support of one more Java UI toolkit — Compose Desktop. Now, you can embed JxBrowser BrowserView into Compose Desktop applications and build modern cross-platform desktop applications with a modern UI toolkit.

To add the JxBrowser Compose Desktop dependency to your project, add the following dependency to your project configuration:

Gradle
dependencies {
    // Adds a dependency for integration with the Compose UI toolkit.
    implementation(jxbrowser.compose)
}

Here is an example of how you can embed JxBrowser Compose BrowserView into a Compose Desktop application:

Kotlin
fun main() = singleWindowApplication {
    val engine = remember { createEngine() }
    val browser = remember { engine.newBrowser() }
    BrowserView(browser)
    DisposableEffect(Unit) {
        browser.navigation.loadUrl("google.com")
        onDispose {
            engine.close()
        }
    }
}

private fun createEngine() = Engine(RenderingMode.OFF_SCREEN) {
    options {
        license = JxBrowserLicense("your_license_key")
    }
}

Gallery examples

You can take a look at the following examples from JxBrowser Gallery to see how you can integrate JxBrowser with Compose Desktop:

Chrome extensions

JxBrowser now provides the Extensions API that allows you to install, update, uninstall, and work with Chrome extensions. It opens up a wide range of possibilities for integrating Chrome extensions into your Java desktop applications.

With the Extensions API, you can:

  • Get a list of installed extensions;
  • Manually install Chrome extensions from Chrome Web Store;
  • Control which extensions can be manually installed by users;
  • Programmatically install Chrome extensions from CRX files;
  • Programmatically uninstall extensions that were installed from Chrome Web Store or CRX files;
  • Control which extensions can be manually uninstalled by users;
  • Get notifications when an extension is installed, updated, or uninstalled;
  • Display extension popups;
  • Simulate extension icon clicks and more.

JxBrowser Chrome Web Store

You can read more about how to work with Chrome extensions in the Extensions guide.

Windows ARM64

JxBrowser now supports Windows ARM64. You can run JxBrowser applications on Windows ARM64 devices, such as Microsoft Surface Pro X or any Copilot+ PC device, and benefit from the improved performance and battery life that ARM64 devices provide.

To run JxBrowser on Windows ARM64, you need to add the following dependency to your Gradle or Maven project configuration:

Gradle
Maven
dependencies {
    implementation(jxbrowser.winArm)
}
<dependency>
    <groupId>com.teamdev.jxbrowser</groupId>
    <artifactId>jxbrowser-win64-arm</artifactId>
    <version>8.0.0</version>
</dependency>

Touch input

You can now programmatically dispatch and handle touch events in the off-screen and hardware accelerated rendering modes on Windows and Linux. It can be useful when you need to simulate touch input in automated tests or when you need to handle touch events in your application.

The following code demonstrates how to programmatically dispatch a touch started event:

Java
Kotlin
browser.dispatch(TouchStarted.newBuilder(
        List.of(TouchPoint.newBuilder(1, Point.of(20, 30), STARTED)
                    .positionInWidget(Point.of(20, 30))
                    .force(0.5F)
                    .radiusX(50)
                    .radiusY(40)
                    .build()))
        .build());
val event = TouchStarted(
    touches = listOf(
        TouchPoint(
            id = 1,
            state = STARTED,
            positionInScreen = Point(20, 30),
            positionInWidget = Point(20, 30),
            force = 0.5F,
            radiusX = 50F,
            radiusY = 40F
        )
    )
)
browser.dispatch(event)

The following code demonstrates how to handle the touch started event:

Java
Kotlin
browser.set(StartTouchCallback.class, params -> {
    var event = params.event();
    var touches = event.touches();
    var targetTouches = event.targetTouches();
    var changedTouches = event.changedTouches();
    var keyModifiers = event.keyModifiers();
    return Response.proceed();
});
browser.register(StartTouchCallback { params ->
    val event = params.event()
    val touches = event.touches()
    val targetTouches = event.targetTouches()
    val changedTouches = event.changedTouches()
    val keyModifiers = event.keyModifiers()
    Response.proceed()
})

You can use StartTouchCallback to suppress the start touch event and prevent it from being dispatched to the web page.

DOM touch events

JxBrowser DOM API allows you to subscribe to the DOM touchstart, touchmove, touchcancel, and touchend events. The following code demonstrates how to subscribe to the touch start events:

Java
Kotlin
var useCapture = false;
element.addEventListener(EventType.TOUCH_START, event -> {
    if (event instanceof TouchEvent touchEvent) {
        touchEvent.touches().forEach(touch -> {
            var id = touch.id();
            var positionInWidget = touch.positionInWidget();
            var positionInScreen = touch.positionInScreen();
            var radiusX = touch.radiusX();
            var radiusY = touch.radiusY();
            var rotationAngle = touch.rotationAngle();
        });
    }
}, useCapture);
val eventType = EventType.TOUCH_START
val listener = Observer<Event> { event ->
    if (event is TouchEvent) {
        event.touches().forEach { touch ->
            val id = touch.id()
            val positionInWidget = touch.positionInWidget()
            val positionInScreen = touch.positionInScreen()
            val radiusX = touch.radiusX()
            val radiusY = touch.radiusY()
            val rotationAngle = touch.rotationAngle()
        }
    }
}
val useCapture = false
element.addEventListener(eventType, listener, useCapture)

Custom DOM events

You can now create and dispatch custom DOM events. The following code demonstrates how to create and dispatch a custom event:

Java
Kotlin
var eventType = EventType.of("WebViewReady");
var eventParams = CustomEventParams.newBuilder(document)
        .detail("true")
        .build();
var event = document.createCustomEvent(eventType, eventParams);
val eventType = EventType.of("WebViewReady")
val eventParams = CustomEventParams(
    document = document,
    payload = "true"
)
val event = document.createCustomEvent(eventType, eventParams)

Passwords, credit cards, user data profiles

Now you can add passwords, credit cards, and user data profiles to the corresponding stores programmatically. In the previous versions, this data could be added to the stores only by the user’s interaction with the browser when the browser prompts the user to save the data.

The following code demonstrates how to add a password to the password store programmatically:

Java
Kotlin
var url = "https://company.com";
var login = "login";
var password = "password";
var passwords = profile.passwordStore();
passwords.add(PasswordRecord.newBuilder(url, password).login(login).build());
val passwords = profile.passwordStore()
passwords.add(
    PasswordRecord(
        url = "https://company.com",
        login = "login",
        password = "password"
    )
)

JxBrowser 7 updates

We will continue upgrading Chromium in JxBrowser 7 during 12 months after the release of JxBrowser 8.0.0. Support for new Java versions and operating systems, new features, improvements, and bug fixes will be available in JxBrowser 8 only. We recommend that you upgrade to JxBrowser 8 to benefit from the new features and improvements.

How to upgrade

If you have a valid JxBrowser license with active support and updates subscription, you can upgrade to JxBrowser 8.0.0 for free.

You can upgrade JxBrowser in your project by changing the version of the JxBrowser dependency in your Gradle or Maven project configuration.

If you have any questions or need assistance with the upgrade, please feel free to contact us.

Download JxBrowser 8.0.0

Please share your email with us, and we'll send you download instructions.

Sending...
Please check your inbox.

We were unable to send the email. Please use the direct link to download JxBrowser.

If you are a registered customer you don't need to do anything to use this update.

If you would like to evaluate the product, you need an evaluation license.

Get free 30-day trial