CheerpJ 2.0 released — now with WebAssembly support
CheerpJ achieves this by:
- Covering 100% of the Java 8 language, including reflection and dynamic class generation;
- Providing a full Java SE runtime library;
- Supporting file system access (read and write), audio, printing through native browser features;
- Supporting Java multi-threading and HTML5 WebWorkers;
- Converting Java from bytecode, without requiring access to the application source code.
Differently from alternative solutions, CheerpJ does not require any change to be made to the source code of the application, supports 100% of the Java language and runtime, and is not a framework and thus in no way opinionated.
CheerpJ is available for Windows, macOS and Linux, and can be downloaded here.
How does CheerpJ work?
The CheerpJ runtime components provide:
- A module to allow transparent support for reflection and dynamic class generation;
- Browser-based implementations of the file system, audio, printing, and other ‘operating system’ features.
- Access and manipulation of the DOM from Java;
How do I use CheerpJ?
Using CheerpJ to convert your Java application is straightforward:
- Compile all your .jar archives using the CheerpJ AOT compiler;
- Minimise your .jar archives (optional, removes all the Java bytecode from the packages);
- Embed your converted application (or link, if a library) in a HTML page, and link to the CheerpJ runtime library.
CheerpJ does not require any server-side support, as all application components (converted application and runtime) are static. You can put a CheerpJ application behind a CDN to virtually cancel any bandwidth costs.
The CheerpJ runtime environment
CheerpJ includes a full Java 8 SE runtime environment, plus a collection of browser-based ‘native’ implementations of different functionalities.
CheerpJ 2.0 introduces for the first time WebAssembly runtime modules, which are used whenever the runtime package is computationally heavy (e.g. font rendering).
The CheerpJ runtime provides extensive support to a number of operating system-like features, including:
- Virtual file systems implemented on top of IndexedDB (read-write access), HTTP(S) (read-only) and strings (read-only);
- Support for real-time audio (via WebAudio);
- Support for printing (via the browser printing dialogue);
- Support for WebWorkers, allowing the development of concurrent applications;
CheerpJ was developed with three main use-case scenarios in mind:
- The conversion of legacy Java applications and Java Applets to HTML5 with minimal or no effort, to extend their life until deprecation, or until a replacement native HTML application has been developed;
- Using (converted) Java libraries as part of a native web application.
The majority of the commercial users of CheerpJ fall into the first two categories. CheerpJ is not intended for writing a web application from scratch, except in the case exemplified in point 3 above. We do not see CheerpJ as a Blazor-equivalent for Java, although anyone is welcome to build a framework on top of it.
CheerpJ and performance
CheerpJ is actively used by a number of commercial applications, as well as in scientific, educational and academic institutions. Many of these applications have stringent performance requirements.
CheerpJ adopts a great range of optimisations to ensure great runtime performance, and small-as-possible download footprint in converted applications:
- Modularised Java 8 runtime. Only the required components of the runtime are downloaded, to minimise the total download footprint. A special debugging feature allows tracking the methods originating the request of each runtime module, to allow further optimisations on the application side.
- Highly-optimised code generation, based on LLVM full-code optimisations. CheerpJ is a full compiler based on LLVM, and as such, it leverages all the full-code optimisations of the LLVM compiler stack.
- Removal of bytecode from .jar archives. CheerpJ requires the original .jar archives to be deployed alongside the application to support reflection and dynamic class generation. However, only the archive structure and metadata are preserved, significantly minimising the download size.
Full Changelog — CheerpJ 2.0
- Introduction of WebAssembly runtime modules to improve runtime speed and reduce the size of packages with heavy computational cost (e.g. font rendering)
- Extended file system support to read, write and delete (IndexedDB backend)
- New read-only filesystem in
/str/for Strings or binary data
- Improved event handling, mouse interaction and focus
- Extend support for charsets
CheerpJ AOT compiler
- Improved robustness to invalid classes often present in real-world JAR archives
- Improved support to multi-threading, in particular Thread.interrupt
- Use the CFGStackifier algorithm to synthesize control flow in generated code
Integration APIs and interoperability
- New API to receive preloading notification (allows to build custom progress bars)
- Improved detection of Applets on HTML pages
- Improved packaging for MacOS
You can find the Documentation for CheerpJ, together with tutorials and examples, on the CheerpJ Documentation page.
To report any issues, please use our issue tracker. For any question or comment, you can find us on the CheerpJ Gitter channel.