CheerpJ 3.0: Run Apps in the Browser with WebAssembly
CheerpJ 3.0 showcases an interesting manifestation of WebAssembly for the browser, demonstrating its potential to deploy and operate complex applications and runtimes written in Java. Developers can create applications in any language and deploy them with just a click — packaged and distributed for availability in testing and usage by end-users.
While CheerpJ 3.0’s development remains ongoing, it represents a significant advancement in deploying applications in the browser with WebAssembly, particularly with Java. This complements other projects focused on encryption and the ability to deploy applications written in C++ for browser usage.

With CheerpJ 3.0 — marking its generally available release — Java client applications, such as Java Applets, Java Web Start applications, and stand-alone Java Applications, can run unmodified on modern browsers, without a local Java installation, the company says. The idea is to make runtimes — in this case Java — better able to run as if the user had the resources of the endpoint server at their disposition — in the browser.
“In the same way that Docker allows you to run containers of binaries on your machine, you need to be able to have the technology and it has technology that allows you to do the same to run binary workloads in the browser in the same way that you can do normally on a normal platform operating system,” Stefano Marco Maria De Rossi, CEO and founder of Leaning Technologies, which created CheerpJ, told The New Stack.
Setting up CheerpJ 3.0 is reasonably straightforward, with clearly outlined steps in the documentation, and it is compatible with essentially any browser, the company says. In the playground aspect, merging PDF files is remarkably simple with the CheerpJ iText. With it, users input their PDF files into the API, and with a few clicks, the files are merged “all done in the browser.” You begin by accessing the iText demo page:

Upload the PDF files you want to merge and merge the documents are indicated:

Merge the PDF files as indicated and you are good to go:

Like the example above, Java can be written and implemented into the WebAssembly module of CheerpJ 3.0 for distribution and execution across browsers of — in theory at least — any application written in Java. There should be many other interesting applications running with CheerpJ for the browser soon in the near future.
One of the funner examples that Leaning Technologies offers to show how it enables Java to run in the browser with CheerpJ is Browsercraft, which allows the game Minecraft to run in the browser so a user can play the game directly (and for free):

Underneath the Hood

Described as a is a WebAssembly Java Virtual Machine for the browser that compiles JIT-compiles Java bytecode into JavaScript (as mentioned above), CheerpJ 3.0 components, according to the documentation, include:
- A WebAssembly JVM and Just-In-Time compiler for Java bytecode. The code contained in class files is 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 via /str/.
- Virtualized networking support via Tailscale. Both server and client applications are supported.
As De Rossi noted when not using WebAssembly, developers must use x86, Linux, or other target architectures separately, whether creating runtime code in Rust, C++, Python, Java or any other language. The code is compiled to run on different platforms. But Wasm represents a unified target. “The key difference is that Wasm is unique and it doesn’t matter if your browser is Chrome on Linux or Safari on macOS or Firefox on Windows,” De Rossi said. “Eventually, Wasm has created this abstraction that allows tool makers to create tools for pretty much any language. Yeah, more and more languages will pop up in the future simply because Wasm is becoming more and more powerful, more and more similar to a native platform.”