Skip to content

Commit

Permalink
video
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielaReyna committed Jan 31, 2025
1 parent afd805a commit 808d5bf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions content/blog/CJ-3-1-roadmap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "CheerpJ 3.1: JVM in WebAssembly and our roadmap for modern Java in the browser "
slug: cheerpj-3.1
description: |
Our state-of-the-art JVM/JDK that runs completely in the browser thanks to WebAssembly, is now available!
Our state-of-the-art JVM/JDK that runs completely in the browser thanks to WebAssembly, is now available!
authors:
- alessandro
- stefano
Expand All @@ -12,6 +12,7 @@ featured: true
tags:
- CheerpJ
---

import LinkButton from "@leaningtech/astro-theme/components/LinkButton.astro";
import { DISCORD_URL } from "@/consts.ts";

Expand Down Expand Up @@ -47,24 +48,25 @@ In combination with library mode, which enables direct usage of Java methods and

## What is CheerpJ?

CheerpJ is a full WebAssembly-based JVM for the browser, and comes with a complete OpenJDK runtime, as well as a powerful emulation layer to provide file system access, general networking support, as well as access to a collection of system devices.
CheerpJ is a full WebAssembly-based JVM for the browser, and comes with a complete OpenJDK runtime, as well as a powerful emulation layer to provide file system access, general networking support, as well as access to a collection of system devices.
CheerpJ is a complete, flexible solution to run Java on modern browsers. It is an extremely powerful tool, designed to work at the scale of real-world, large Enterprise applications.

### Features

CheerpJ’s main capabilities are:

- **Running unmodified Java applications on modern browsers without plugins, or a Java installation.** Stand-alone Java Applications, Java Web Start, Java Applets are supported. No server side component is required. All the code is run on the client via WebAssembly and JavaScript.
- **Works from unmodified JAR files (no need for source code)**, no need for any compilation or preprocessing step. Works with obfuscated bytecode, independently of the obfuscator being used.
- **Supports _very large_ applications**, our stress test is IntelliJ IDEA 2019 which ships ~400MBs of JARs. [Check it out](https://x.com/alexpignotti/status/1729915428258926713).
- **Supports _very large_ applications**, our stress test is IntelliJ IDEA 2019 which ships ~400MBs of JARs. [Check it out](https://x.com/alexpignotti/status/1729915428258926713).
- **Supports graphical applications**, both AWT- and Swing-based ones are supported, including third-party Look&Feels. Multiple applications, each with multiple windows, can run at the same time.
- **Full support for reflection and classloaders**, including custom ones designed to support plugins or encrypted JARs.
- **Powerful interoperability with JavaScript**
- [Library mode](https://cheerpj.com/docs/guides/library-mode): A new solution to integrate Java libraries into Web applications using a clean `async/await` interface
- [JavaScript natives](https://cheerpj.com/docs/guides/implementing-native-methods), making it possible to implement Java `native` methods (JNI) directly in JavaScript with a convenient interface. This feature can also be used to interact with JavaScript and DOM APIs from Java.
- [Library mode](https://cheerpj.com/docs/guides/library-mode): A new solution to integrate Java libraries into Web applications using a clean `async/await` interface
- [JavaScript natives](https://cheerpj.com/docs/guides/implementing-native-methods), making it possible to implement Java `native` methods (JNI) directly in JavaScript with a convenient interface. This feature can also be used to interact with JavaScript and DOM APIs from Java.

In short, thanks to CheerpJ most Java applications and libraries can be run in the browser without any additional work or changes to the code.

CheerpJ 3.1 is the last release of CheerpJ to focus exclusively on Java 8 support.
CheerpJ 3.1 is the last release of CheerpJ to focus exclusively on Java 8 support.

Support for modern versions of Java is already underway, and we are targeting support for Java 11 as part of the upcoming CheerpJ 4.0 release, with Java 17 following later in the year. In the long term, we aim to reach parity with the most recent Java LTS version, while preserving support for Java 8 and all intermediate LTS versions.

Expand All @@ -74,24 +76,24 @@ CheerpJ is a commercial product and professionally supported, but it’s also fr

![CheerpJ architecture](./cheerpj-3-deep-dive-arch.png)

CheerpJ is a Java Virtual Machine in WebAssembly for the browser, which JIT-compiles Java bytecode into JavaScript.
CheerpJ is a Java Virtual Machine in WebAssembly for the browser, which JIT-compiles Java bytecode into JavaScript.
It is a sophisticated tool with many moving parts, the main ones being:

- A WebAssembly **JVM and Just-In-Time compiler for** Java bytecode. The code contained in class files is dynamically compiled and optimized. The JIT compiler supports advanced optimizations such as inlining and dynamic devirtualization.
- A WebAssembly **JVM and Just-In-Time compiler for** Java bytecode. The code contained in class files is dynamically compiled and optimized. The JIT compiler supports advanced optimizations such as inlining and dynamic devirtualization.
- A complete and unmodified build of **OpenJDK**.
- **A virtualized system layer, including:**
- [Virtualized file systems](https://cheerpj.com/docs/guides/File-System-support), providing access to assets over HTTP, local persistent R/W storage via IndexedDB and interaction with JavaScript data.
- [Virtualized networking](https://cheerpj.com/docs/guides/Networking) support via Tailscale. Both server and client applications are supported.
- Seamless clipboard integration using the [Clipboard API](https://cheerpj.com/docs/reference/cheerpjInit#clipboardmode).
- A window manager, to support multiple Java windows and multiple Java applications in the same Web page.
- [Virtualized file systems](https://cheerpj.com/docs/guides/File-System-support), providing access to assets over HTTP, local persistent R/W storage via IndexedDB and interaction with JavaScript data.
- [Virtualized networking](https://cheerpj.com/docs/guides/Networking) support via Tailscale. Both server and client applications are supported.
- Seamless clipboard integration using the [Clipboard API](https://cheerpj.com/docs/reference/cheerpjInit#clipboardmode).
- A window manager, to support multiple Java windows and multiple Java applications in the same Web page.

For more details about the design of CheerpJ, please refer to [the deep dive](/blog/cheerpj-3-deep-dive) we published at the time of the initial CheerpJ 3.0 release. You can also read the [architecture page](https://cheerpj.com/docs/explanation/architecture) in the CheerpJ documentation.

## The Roadmap for Modern Java in the browser

![CheerpJ roadmap](./roadmapcj3.png)

Our vision for CheerpJ does not stop with Java 8, and is not limited to its role as a tool to run legacy Java applications.
Our vision for CheerpJ does not stop with Java 8, and is not limited to its role as a tool to run legacy Java applications.

We are finally ready to announce that plans are in place for CheerpJ to support more modern Java versions (and corresponding OpenJDK runtimes), with a long-term ambition to reach parity with latest LTS releases of Java.

Expand All @@ -107,13 +109,15 @@ While all this sounds exciting, it’s not the end of the story. CheerpJ 4.0 and

CheerpJ 3.1 can effectively run any Java application in the browser, but the reality is that many Java applications are not _actually_ 100% Java.

It’s fairly common to find Java applications that make extensive use of JNI code to access libraries or system capabilities that are not available to Java otherwise. This has historically been a considerable real-world limitation of CheerpJ, and up to CheerpJ 3.1 we could only offer the use of [JavaScript natives](https://cheerpj.com/docs/guides/implementing-native-libraries) as a workaround.
It’s fairly common to find Java applications that make extensive use of JNI code to access libraries or system capabilities that are not available to Java otherwise. This has historically been a considerable real-world limitation of CheerpJ, and up to CheerpJ 3.1 we could only offer the use of [JavaScript natives](https://cheerpj.com/docs/guides/implementing-native-libraries) as a workaround.

CheerpJ 4.0 will introduce support for WebAssembly JNI modules, providing a complete solution for all cases where the C/C++ JNI code is available.

To understand the promise and scope of this new feature, let’s consider a popular use case of CheerpJ: running Minecraft on the browser.

[NEW MINECRAFT DEMO + CAPTION]
<video controls autoplay loop muted playsinline>
<source src="./minecraft_video.mp4" type="video/mp4" />
</video>

To keep things simple let’s focus on the Minecraft 1.0 release. It was composed of `client.jar` containing all the game logic, and LWJGL: a Java library to access OpenGL rendering. All the logic in `client.jar` works correctly in CheerpJ, already in the 3.0 [release](https://browsercraft.cheerpj.com/).

Expand All @@ -136,7 +140,7 @@ All these WebAssembly modules can be generated without any change to the origina

### All of this, only for Minecraft?

As it often happens with our [development tools](https://labs.leaningtech.com/), solutions might be inspired by a specific use case, but are always designed to be generic.
As it often happens with our [development tools](https://labs.leaningtech.com/), solutions might be inspired by a specific use case, but are always designed to be generic.

Popular toolkits such as SWT and JavaFX, that are also not currently supported by CheerpJ, have very similar characteristics to the Minecraft/LWJGL use case:

Expand All @@ -145,7 +149,7 @@ Popular toolkits such as SWT and JavaFX, that are also not currently supported b
- **X11 requirement**, particularly for SWT;
- **OpenGL requirement**, particularly for JavaFX.

It is quite clear that the building blocks to successfully run Minecraft in CheerpJ are the same required to achieve SWT and JavaFX support.
It is quite clear that the building blocks to successfully run Minecraft in CheerpJ are the same required to achieve SWT and JavaFX support.

The timeline for supporting these toolkits is not yet finalised, and they might be included only after the CheerpJ 4.0 release, but the good news is that they can all be supported within the existing CheerpJ architecture.

Expand All @@ -157,7 +161,7 @@ The future of CheerpJ, starting from the release of CheerpJ 4.0,will greatly ext

In addition, CheerpJ is not limited to targeting existing Java applications. Thanks to [library mode](https://cheerpj.com/docs/guides/library-mode), it is possible to use Java libraries directly from JavaScript with natural async/await syntax, and embed them in Web applications.

We believe that CheerpJ and WebAssembly will enable Java to become a first-class programming language for the Web, opening the door to a new generation of Web native Java-powered client applications. We hope you find these possibilities as exciting as we do.
We believe that CheerpJ and WebAssembly will enable Java to become a first-class programming language for the Web, opening the door to a new generation of Web native Java-powered client applications. We hope you find these possibilities as exciting as we do.

### Get started

Expand All @@ -182,7 +186,6 @@ CheerpJ is [extensively documented](/cheerpj3), ranging from basic tutorials to
iconRight="mi:arrow-right"
/>


### Community

For questions, discussion, and support, [join our Discord](https://discord.leaningtech.com). It’s an active community where both Leaning Technologies developers and experienced users can provide help.
Expand Down
Binary file added content/blog/minecraft_video.mp4
Binary file not shown.

0 comments on commit 808d5bf

Please sign in to comment.