Today we are happy to announce CheerpJ 4.0, the latest major release of CheerpJ, a Java Virtual Machine and OpenJDK distribution in WebAssembly, designed to run Java applications and libraries in the browser.
CheerpJ 4.0 is the first version to support both Java 8 and Java 11, an essential step along our roadmap to bring modern Java to the browser. Support for Java 17- the next step along this path - is planned for later in the year as part of the CheerpJ 5.0 milestone. We expect to achieve LTS parity by the end of 2026.
In addition to Java 11 support, CheerpJ 4.0 also improves mobile usability, introduces support for WebAssembly JNI modules, and brings significant performance improvements.
In combination with Library Mode, which provides very advanced JavaScript-Java interoperability, we believe CheerpJ is now closer than ever to our vision of making Java a first-class programming language for the Web.
What can CheerpJ do?
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 and other OS-level features. It works fully client-side, via WebAssembly, JavaScript and HTML5 technologies. It is, in essence, a JavaScript library, with no server-side or cloud-based component of any sort.
CheerpJ is a complete, flexible Java platform for modern browsers. It is an extremely powerful tool, designed and tested to work at the scale of real-world, large enterprise applications. Here is an overview of what CheerpJ can be used for.
Running large-scale Swing / AWT applications
CheerpJ can run existing, full Java applications from unmodified JARs, with no recompilation or pre-processing, straight from bytecode. Obfuscated or encrypted JARs are supported irrespective of the obfuscator being used.
A complex Swing application running live. Use the bottom-right control button to try it fullscreen.
Both AWT- and Swing-based applications are supported, including third-party Swing Look&Feels. Multiple applications, each with multiple windows, can run at the same time on the same page.
CheerpJ 4.0 introduces an unprecedented level of support for mobile devices, enabling for the first time to make complex Java applications available to users across phones and, especially, tablets.
Running a Java application is straightforward, requiring just three calls to the CheerpJ APIs (see our Getting Started guide for a fully worked example).
await cheerpjInit();cheerpjCreateDisplay(800, 600);await cheerpjRunJar("/app/my_application_archive.jar");
CheerpJ is built to run Java bytecode at scale, and is robust to very large applications. As a point of reference, our internal stress test is IntelliJ IDEA, an application comprising around 400MB of JAR files.
Using Java libraries as part of Web Applications
CheerpJ makes it possible to use Java libraries from JavaScript using a natural and expressive async
/await
based approach, we call this feature Library Mode.
The following snippet of code should give an idea about this capability, by using the popular iText
library to generate a PDF completely client-side in the browser.
async function iTextExample() { await cheerpjInit(); const lib = await cheerpjRunLibrary("/app/itextpdf-5.5.13.3.jar"); try { const Document = await lib.com.itextpdf.text.Document; const Paragraph = await lib.com.itextpdf.text.Paragraph; const PdfWriter = await lib.com.itextpdf.text.pdf.PdfWriter; const FileOutputStream = await lib.java.io.FileOutputStream; const document = await new Document(); const writer = await PdfWriter.getInstance( document, await new FileOutputStream("/files/HelloIText.pdf") ); await document.open(); await document.add(await new Paragraph("Hello World!")); await document.close(); await writer.close(); const blob = await cjFileBlob("/files/HelloIText.pdf"); const url = URL.createObjectURL(blob); pdfDisplay.data = url; } catch (e) { const IOException = await lib.java.io.IOException; if (e instanceof IOException) console.log("I/O error"); else console.log("Unknown error: " + (await e.getMessage())); }}
Library Mode provides extensive access to Java, with these main features:
- Creating new objects
- Calling static and instance methods. Overloading is supported and the correct method is resolved taking into account the argument types.
- Accessing static and instance fields, both for reading and for writing.
- Handling Java exceptions from JavaScript (via regular
try
/catch
blocks)
Library Mode is a unique feature, which makes it possible to build a new generation of fully client-side Web applications that combine Web-native components with Java libraries to implement complex functionalities.
In more enterprise scenarios, this approach can be used to progressively migrate large-scale Java applications to native Web apps, by rewriting the UI while keeping all or part of the original business logic in Java. This can provide significant reduction of risk, costs, and timeline to large modernisation projects.
Check out our dedicated documentation for more information on Library Mode
Running legacy Java Applets and Java Web Start
On top of the core CheerpJ technology we have built specialized browser extensions, CheerpJ Applet Runner and CheerpJ JNLP Runner
, to run applets and Java Web Start applications without any manual integration steps.
Both extensions are available for Chrome and Edge and have been very popular, with hundreds of thousands of users all over the world.
These tools are particularly suited for end-users who simply need to access legacy Java client applications on modern setups, and for organisations that are testing and evaluating CheerpJ.
How does CheerpJ work
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 complete and unmodified build of OpenJDK.
- A virtualized system layer, including:
- Virtualized file systems
, providing access to assets over HTTP, local persistent R/W storage via IndexedDB and interaction with JavaScript data.
- Virtualized networking
support via Tailscale. Both server and client applications are supported.
- Seamless clipboard integration using the Clipboard API
.
- A window manager, to support multiple Java windows and multiple Java applications in the same Web page.
- Virtualized file systems
For more details about the design of CheerpJ, please refer to the deep dive we published at the time of the initial CheerpJ 3.0 release. You can also read the architecture page
in the CheerpJ documentation.
Demo: Unmodified Minecraft in the browser
To showcase the capabilities of CheerpJ, we created a side project named Browsercraft, a web-based “embedding” of a historical Java version of Minecraft.
Contrary to other approaches you might have seen, Browsercraft is not based on decompilation or reverse engineering attempts. The original client.jar
is fetched directly from Mojang servers on the end-user browser and runs unmodified. The LWJGL dependency, available from Maven, is also unmodified.
How LWJGL works in CheerpJ is particularly interesting, since it is 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.
CheerpJ 4.0 introduces support for these scenarios via JNI WebAssembly modules, which are loaded and executed dynamically, similarly to what happens on native platforms via shared libraries. Browsercraft takes advantage of this capability for LWJGL native code and also for the gl4es library. This latter component provides a compatibility layer between OpenGL, used by Minecraft, and GLES as provided by WebGL.
By combining these WebAssembly modules and the unmodified JARs, CheerpJ can now correctly render Minecraft in the browser. It should be noted that Minecraft is a notoriously inefficient and resource intensive application, so we consider it to be a stress test for CheerpJ. Nevertheless, thanks to recent improvements in our JIT compiler, the demo can now run with satisfactory performance on most mid range machines. The situation will further improve in the future thanks to more advanced optimizations currently planned, stay tuned.
What’s next?
CheerpJ 4.0 greatly extends what can be achieved with CheerpJ, thanks to Java 11 support, WebAssembly JNI modules and improved support for mobile devices. The upcoming 5.0 release, scheduled for late 2025, will bring us even closer to running any modern Java application in the browser.
A few major updates we expect to ship soon are:
- Support for Java 17: This will be introduced as part of CheerpJ 5.0. The implementation is already at the prototypical stage, and available on request to interested parties. We expect general availability of Java 17 before the end of 2025. Get in touch if you are interested in early access!
- Support for JavaFX / SWT: WebAssembly JNI modules, as described above in the context of Browsercraft, will be a critical component to introduce support for JavaFX and SWT. Similarly to LWJGL, these libraries are only superficially Java, with most of the logic being implemented as platform-specific, C and C++ code. We plan to compile all this code to WebAssembly, taking advantage of upcoming improvements to our C++ to WebAssembly and JavaScript compiler Cheerp
- General availability for JNI headers and libraries: We compile WebAssembly JNI modules thanks to custom implementation of the JNI headers and libraries, specifically designed to work with the CheerpJ JVM. We plan to release these so that users may compile their own WebAssembly JNI modules. Thanks to this an even greater range of Java applications will be supported.
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.
Licensing
CheerpJ is commercial software, but it’s free to use for FOSS projects, personal projects and one-person companies. Affordable and transparent licensing apply to small businesses.
Enterprise licensing and support are available, with significant discounts for non-profit and educational institutions. For more information see Licensing.
Try it out and join the community
CheerpJ is extensively documented, ranging from basic tutorials to the detailed API reference.
For questions, discussion, and support, join our Discord. It’s an active community where both Leaning Technologies developers and experienced users can provide help.
Following the success of the second edition of the WebVM Hackathon earlier this year, we have decided to host the first CheerpJ Hackathon
. The event theme and precise dates are still being determined, but it will be a week-long competition to be held between September and October 2025, with a £500 prize awaiting the winning team. Sign up now
to stay updated.
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.
Star CheerpJ on GitHub