Skip to content

Commit 37825bd

Browse files
committed
Merge remote-tracking branch 'origin/main' into CheerpX_Datadevice
2 parents 5166764 + e836ffb commit 37825bd

File tree

65 files changed

+771
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+771
-211
lines changed

content/blog/CJ-3-1-roadmap.mdx

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
title: "CheerpJ 3.1: JVM in WebAssembly and our roadmap for modern Java in the browser "
3+
slug: cheerpj-3.1
4+
description: |
5+
Our state-of-the-art JVM/JDK that runs completely in the browser thanks to WebAssembly, is now available!
6+
authors:
7+
- alessandro
8+
- stefano
9+
pubDate: "February 5 2025"
10+
heroImage: "./CJ3-1.png"
11+
featured: true
12+
tags:
13+
- CheerpJ
14+
---
15+
16+
import LinkButton from "@leaningtech/astro-theme/components/LinkButton.astro";
17+
import { DISCORD_URL } from "@/consts.ts";
18+
19+
In this post, we’ll provide an overview of CheerpJ, the capabilities of the current release, and our ambitious plans for the future of Java and OpenJDK on the browser.
20+
21+
<div class="flex items-center gap-2 flex-wrap">
22+
<LinkButton
23+
type="primary"
24+
href="https://cheerpj.com/docs/getting-started"
25+
target="_blank"
26+
label="Get started"
27+
iconRight="mi:arrow-right"
28+
/>
29+
30+
<LinkButton
31+
type="discord"
32+
href={DISCORD_URL}
33+
target="_blank"
34+
iconLeft="fa-brands:discord"
35+
label="Join the Discord server"
36+
/>
37+
</div>
38+
39+
CheerpJ 3.1 is the latest stable release of the new CheerpJ architecture introduced as part of CheerpJ 3.0, first announced on [May 9th, 2023](https://labs.leaningtech.com/blog/announcing-cheerpj-3) and released on [February 1st, 2024](https://labs.leaningtech.com/blog/cheerpj-3.0).
40+
41+
The new architecture, built around a pure-JIT JVM in WebAssembly, has been an outstanding success, delivering on its promise of making CheerpJ faster, simpler to use and compatible with the vast majority of Java applications and applets. Virtually all users of CheerpJ core, as well as of our browser extensions, have seamlessly transitioned to the new architecture in the span of the last six months.
42+
43+
In CheerpJ 3.0, some features were still lacking compared to the legacy CheerpJ 2.3 release, with audio support being the most prominent. Moreover, notwithstanding our intense testing, several bugs and regressions were found by users.
44+
45+
CheerpJ 3.1 is a stability-focused release that restores support for all the features lost in the transition to the new architecture and fixes all the bugs we have found after exposing CheerpJ to large real-world workloads.
46+
47+
The end result is the most robust release of CheerpJ ever, and a stepping stone for the upcoming CheerpJ 4.0 release, that will bring Java 11+ support, loadable JNI modules, JavaFX support and improved mobile usability. And will even run Minecraft properly!
48+
49+
In combination with library mode, which enables direct usage of Java methods and objects from JavaScript, we believe CheerpJ is now closer than ever to our vision: Making Java a first-class programming language for the Web.
50+
51+
## What is CheerpJ?
52+
53+
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.
54+
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.
55+
56+
### Features
57+
58+
CheerpJ’s main capabilities are:
59+
60+
- **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.
61+
- **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.
62+
- **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).
63+
- **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.
64+
- **Full support for reflection and classloaders**, including custom ones designed to support plugins or encrypted JARs.
65+
- **Powerful interoperability with JavaScript**
66+
- [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
67+
- [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.
68+
69+
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.
70+
71+
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.
72+
73+
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.
74+
75+
CheerpJ is a commercial product and professionally supported, but it’s also free for personal use. View [licensing](https://cheerpj.com/docs/licensing) for more details.
76+
77+
### How does CheerpJ work?
78+
79+
![CheerpJ architecture](./cheerpj-3-deep-dive-arch.png)
80+
81+
CheerpJ is a Java Virtual Machine in WebAssembly for the browser, which JIT-compiles Java bytecode into JavaScript.
82+
It is a sophisticated tool with many moving parts, the main ones being:
83+
84+
- 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.
85+
- A complete and unmodified build of **OpenJDK**.
86+
- **A virtualized system layer, including:**
87+
- [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.
88+
- [Virtualized networking](https://cheerpj.com/docs/guides/Networking) support via Tailscale. Both server and client applications are supported.
89+
- Seamless clipboard integration using the [Clipboard API](https://cheerpj.com/docs/reference/cheerpjInit#clipboardmode).
90+
- A window manager, to support multiple Java windows and multiple Java applications in the same Web page.
91+
92+
For more details about the design of CheerpJ, please refer to [the deep dive](https://labs.leaningtech.com/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.
93+
94+
## The Roadmap for Modern Java in the browser
95+
96+
![CheerpJ roadmap](./roadmapcj3.png)
97+
98+
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.
99+
100+
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.
101+
102+
Work to support Java 11+ is already well underway and will be merged to nightly builds as soon as possible after this release. This will constitute the key novel element of the next major release of CheerpJ, 4.0, which we expect between March and April 2025, with Java 17 support following later in the year. Support for Java 21 will be added in 2026, although the timeline might become more aggressive depending on commercial demand. In the longer term we plan to maintain LTS parity in CheerpJ, to fulfil our goal of making any Java applications run unmodified in the browser.
103+
104+
With these developments, we are on a course to realise the full ambition of CheerpJ: a full Java environment for modern browsers, centred around up-to-date builds of OpenJDK, and a JVM in WebAssembly.
105+
106+
Java developers will be able to look at the browser as just another target to distribute applications or libraries on, enabling a new generation of Web-enabled Java clients.
107+
108+
While all this sounds exciting, it’s not the end of the story. CheerpJ 4.0 and future releases will not only introduce support for modern Java, but also new functionality that will allow applications that are not written in pure Java to also run on the browser.
109+
110+
### What about Java apps with JNI components?
111+
112+
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.
113+
114+
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.
115+
116+
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.
117+
118+
To understand the promise and scope of this new feature, let’s consider a popular use case of CheerpJ: running Minecraft on the browser.
119+
120+
<video controls autoplay loop muted playsinline>
121+
<source src="./minecraft_video.mp4" type="video/mp4" />
122+
</video>
123+
124+
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/).
125+
126+
LWJGL, on the other hand, it’s only superficially Java. Most of its value comes from JNI methods which provide direct access to each and every method exposed by OpenGL. These methods are written in C and automatically generated by the LWJGL build system from a declarative representation of the OpenGL API.
127+
128+
As of the 3.0 release we could get Minecraft to partially work by manually implementing a small subset of the LWJGL [JNI methods](https://github.com/leaningtech/cheerpj-natives) directly in JavaScript, but this method turned out to be extremely time consuming. Moreover, Minecraft is built on legacy OpenGL techniques which do not directly map to WebGL capabilities. The end result was promising but underwhelming, with lots of manual effort required to achieve a poorly rendered and slow version of the game.
129+
130+
The solution to all these problems is to simply compile even more things to Wasm. CheerpJ 4.0 will support loading of WebAssembly modules at runtime. These modules can be generated from C/C++ code coming from either JNI modules or arbitrary libraries required by Java applications.
131+
132+
In the case of Minecraft there are several components:
133+
134+
- **lwjgl2.wasm**: Is generated from the unmodified C code generated by the LWJGL build system. It exposes all the native methods of LWJGL, completely removing the need to manually write any code in JavaScript.
135+
- **gl4es.wasm**: Is a WebAssembly build of [gl4es](https://github.com/ptitSeb/gl4es/), a FOSS library that implements legacy GL on top of GLES.
136+
- **gles.wasm**: A WebAssembly module mapping GLES APIs to WebGL, which will be automatically provided by CheerpJ.
137+
- **X11.wasm**: A background process providing X11 emulation to integrate Java windows and windows created for OpenGL rendering.
138+
139+
The end result of this stack is Minecraft rendering correctly in the browser via CheerpJ, with the level of performance being already quite good and with more improvements planned before CheerpJ 4.0 is released.
140+
141+
All these WebAssembly modules can be generated without any change to the original code using Cheerp, our C/C++ to WebAssembly/JavaScript compiler. This is possible thanks to new [Cheerp](https://cheerp.io) features that will soon support compiling any unmodified Linux C/C++ applications to WebAssembly. Stay tuned for more information and join our [Discord server](https://discord.leaningtech.com/) to be always updated on all our products.
142+
143+
### All of this, only for Minecraft?
144+
145+
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.
146+
147+
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:
148+
149+
- **Shallow Java surface** with lots of C/C++ JNI logic
150+
- **Dependency on large C libraries**, GTK in particular
151+
- **X11 requirement**, particularly for SWT
152+
- **OpenGL requirement**, particularly for JavaFX
153+
154+
It is clear that the building blocks to successfully run Minecraft in CheerpJ are the same required to achieve SWT and JavaFX support.
155+
156+
The timeline for supporting these toolkits is not yet finalised, and they might be included only after the CheerpJ 4.0 release, but they can all be supported within the existing CheerpJ architecture.
157+
158+
### Our vision: Java as a first-class programming language in the browser
159+
160+
CheerpJ 3.1, released today, confirms our commitment to offer the best-in-class solution to run any pure Java 8 application on modern browsers.
161+
162+
The future of CheerpJ, starting from the release of CheerpJ 4.0,will greatly extend what can be achieved with CheerpJ, bringing support for modern Java (starting with Java 11), loadable JNI modules (for LWJGL, SWT and JavaFX) and improved support for mobile input handling.
163+
164+
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.
165+
166+
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.
167+
168+
## Get started
169+
170+
### 1. Add the loader
171+
172+
```html
173+
<script src="https://cjrtnc.leaningtech.com/3.1/cj3loader.js"></script>
174+
```
175+
176+
### 2. Initialize the virtual machine
177+
178+
```js
179+
await cheerpjInit();
180+
```
181+
182+
CheerpJ is [extensively documented](https://cheerpj.com/docs), ranging from basic tutorials to the detailed API reference.
183+
184+
<LinkButton
185+
type="primary"
186+
href="https://cheerpj.com/docs/getting-started"
187+
target="_blank"
188+
label="Get started"
189+
iconRight="mi:arrow-right"
190+
/>
191+
192+
## Community
193+
194+
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.
195+
196+
---
197+
198+
CheerpJ is a product built with passion and a lot of coffee by Leaning Technologies, an international team of WebAssembly hackers based in Amsterdam (NL) and Leeds (UK). We hope you’ll love it as much as we do.
199+
200+
<LinkButton
201+
href="https://github.com/leaningtech/cheerpj-meta"
202+
target="_blank"
203+
type="secondary"
204+
label="Star CheerpJ on GitHub"
205+
iconLeft="fa:star"
206+
/>

content/blog/CJ3-1.png

126 KB
Loading

content/blog/cheerpj-3-deep-dive.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { DISCORD_URL } from "@/consts.ts";
2222
<div class="flex items-center gap-2 flex-wrap">
2323
<LinkButton
2424
type="primary"
25-
href="/cheerpj3/getting-started"
25+
href="https://cheerpj.com/docs/getting-started"
2626
label="Get started with CheerpJ"
2727
iconRight="mi:arrow-right"
2828
/>
@@ -215,7 +215,7 @@ The new library mode API is also used for [`native` methods implemented in JavaS
215215

216216
You might be wondering what use cases can CheerpJ support:
217217

218-
- **Restoration of legacy gaming, educational or personal content:** Especially if packaged as applets, bringing them back to life with CheerpJ is just a matter of including the loader and calling a single line of JavaScript. [Try it now](/cheerpj3/getting-started).
218+
- **Restoration of legacy gaming, educational or personal content:** Especially if packaged as applets, bringing them back to life with CheerpJ is just a matter of including the loader and calling a single line of JavaScript. [Try it now](https://cheerpj.com/docs/getting-started).
219219
- **Modernization of enterprise software:** This includes Oracle Forms, EBS and similar Java based enterprise solutions, that are still widely used in Enterprise settings.
220220
- **Building Web Applications with Java libraries:** CheerpJ can bring the power of Java libraries to Web apps. Thanks to library mode, Java libraries can now be integrated in Web applications via CheerpJ, rather than requiring a server-side component to run them.
221221
- **Fully client-side Java development environments and playgrounds:** The `javac` compiler is itself written in Java and can run with CheerpJ. We showcase this in our [JavaFiddle playground](https://javafiddle.leaningtech.com) and the [full source code](https://github.com/leaningtech/javafiddle) is available if you want to delve deeper.
@@ -248,7 +248,7 @@ You can use CheerpJ by simply adding a script tag to any HTML page:
248248
<div class="pt-2">
249249
<LinkButton
250250
type="primary"
251-
href="/cheerpj3/getting-started"
251+
href="https://cheerpj.com/docs/getting-started"
252252
label="Get started"
253253
iconRight="mi:arrow-right"
254254
/>

content/blog/cheerpj-3.0.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exciting demo we've been working on.
2424
<div class="flex items-center gap-2 flex-wrap">
2525
<LinkButton
2626
type="primary"
27-
href="/cheerpj3/getting-started"
27+
href="https://cheerpj.com/docs/getting-started"
2828
label="Get started"
2929
iconRight="mi:arrow-right"
3030
/>
@@ -135,7 +135,7 @@ CheerpJ is [extensively documented](/cheerpj3), ranging from basic tutorials to
135135

136136
<LinkButton
137137
type="primary"
138-
href="/cheerpj3/getting-started"
138+
href="https://cheerpj.com/docs/getting-started"
139139
label="Get started"
140140
iconRight="mi:arrow-right"
141141
/>

content/blog/cheerpj-3.0rc1.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ import LinkButton from "@leaningtech/astro-theme/components/LinkButton.astro";
101101

102102
<LinkButton
103103
type="primary"
104-
href="/cheerpj3/getting-started"
104+
href="https://cheerpj.com/docs/getting-started"
105105
label="Get started"
106106
iconRight="mi:arrow-right"
107107
/>

content/blog/cheerpj-3.0rc2.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ import LinkButton from "@leaningtech/astro-theme/components/LinkButton.astro";
103103
104104
<LinkButton
105105
type="primary"
106-
href="/cheerpj3/getting-started"
106+
href="https://cheerpj.com/docs/getting-started"
107107
label="Get started"
108108
iconRight="mi:arrow-right"
109109
/>

content/blog/cx-1.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ cx.setConsole(document.getElementById("console"));
135135
await cx.run("/usr/bin/python3", []);
136136
```
137137

138-
That’s it. The user will now be able to try Python code in the browser. The basic _builtin console_ is sufficient for quick experimentation, but you should consider using the full-fledged [xterm.js](https://xtermjs.org/) terminal emulator for better results. You can do so using the [`cx.setCustomConsole` API](https://cheerpx.io/docs/reference/CheerpX-Linux-setCustomConsole)
138+
That’s it. The user will now be able to try Python code in the browser. The basic _builtin console_ is sufficient for quick experimentation, but you should consider using the full-fledged [xterm.js](https://xtermjs.org/) terminal emulator for better results. You can do so using the [`cx.setCustomConsole` API](/docs/reference/CheerpX.Linux/setCustomConsole)
139139

140140
![Python in the browser](./images/cx10_python.png)
141141

content/blog/roadmapcj3.png

1000 KB
Loading

packages/astro-theme/components/ProductVersionSwitcher.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { product } = Astro.props;
1414
class="px-2 py-1 rounded bg-transparent text-stone-400 font-medium"
1515
id="version-switcher"
1616
>
17-
<option value="cheerpj3" selected={product.id === "cheerpj3"}>v3.0</option>
17+
<option value="cheerpj3" selected={product.id === "cheerpj3"}>v3.1</option>
1818
<option value="cheerpj2" selected={product.id === "cheerpj2"}>v2.3</option>
1919
</select>
2020
</div>

0 commit comments

Comments
 (0)