Announcing CheerpJ 1.0 — the most advanced Java-to-JavaScript solution on the market

(originally published on March 29, 2018)

We are happy to announce the first stable release of CheerpJ, our Java-to-JavaScript solution to automatically convert any Java application to an HTML5 web app.

After two years of development, close to a year of intensive collaborative work with several early adopters, and six months of public beta, we think that CheerpJ has become a mature, performant and stable solution for the conversion of Java to JavaScript.

Differently from alternative solutions such as TeaVM, GWT or JSweet, CheerpJ seeks to enable the automated conversion of legacy Java applications into JavaScript with close to no manual intervention.

CheerpJ 1.0 achieves this by:

  • Covering 100% of the Java 8 language, including native reflection and dynamic class generation;
  • Covering 100% of the Java SE runtime library;
  • Supporting file system access (read and write), audio, printing through native browser features;
  • Supporting Java multi-threading and allowing to develop concurrent applications leveraging WebWorkers;
  • Converting Java from bytecode, without requiring access to the application source code.

In a nutshell, CheerpJ is Java bytecode-to-JavaScript compiler, plus a full Java 8 runtime and a browser-based suite of “operating system” features. As such, it allows virtually any Java application to be converted to JavaScript without manual intervention, irrespective of the framework being used (e.g. Spring).

CheerpJ 1.0 is available for Windows, macOS and Linux, and can be downloaded here. CheerpJ applications are standard JavaScript and can run on any OS (including mobile), and any browser with JavaScript support, including IE.

What is CheerpJ?

CheerpJ is a solution for the conversion of Java applications, libraries and Java applets into JavaScript. It consists of three components:

The CheerpJ AOT compiler, a Java-bytecode-to-JavaScript compiler based on LLVM as well as on the Cheerp C/C++ to JavaScript compiler;

The CheerpJ runtime components, providing:

  • A complete, modular Java 8 SE runtime library in JavaScript;
  • Native reflection and dynamic class generation;
  • Browser-based implementations of file system, audio, printing, and other ‘operating system’ features.

The CheerpJ JavaScript / DOM interoperability APIs, allowing:

  • Access and manipulation of the DOM from Java;
  • Implementation of ‘native’ Java methods in JavaScript;
  • Access to converted Java libraries from JavaScript.

Converting a Java application to JavaScript with CheerpJ consists in three simple steps:

  • Compile all your .jar archives to JavaScript using the CheerpJ AOT compiler;
  • Minimise your .jar archives;
  • Build a simple HTML page, and serve the JavaScript output, minimised .jar archives, and HTML page with any web server.

CheerpJ does not require any server side support, as all application components are static. You can put a CheerpJ application behind a CDN to virtually cancel any bandwidth costs.

CheerpJ runtime environment and OS features

CheerpJ includes a full Java 8 SE runtime environment, plus a collection of browser-based ‘native’ implementations of different functionalities.

Some of the most interesting are:

  • Read-write persistent file system support, via IndexedDB. Read-only file system support via HTTP;
  • Support for real-time audio (via WebAudio);
  • Support for printing (via the browser printing dialogue);
  • Support for DOM manipulation, as well as invoking JavaScript from Java;
  • Support for WebWorkers, allowing the development of concurrent applications.

What can CheerpJ be used for?

CheerpJ was developed with three main use-case scenarios in mind:

  • Allowing the conversion of legacy Java applications and Java applets to JavaScript with minimal effort;
  • Allowing to extend converted Java apps to use modern browser features, such as DOM manipulation or the integration with a JavaScript framework;
  • Allowing to convert complex Java libraries to JavaScript.

Any example of CheerpJ in action?

CheerpJ has been used by many applications, most of which commercial, since the start of our early adopter program last year, some of them already having reached the market.

We think the best representation of CheerpJ capabilities and performance is the Blackbird JavaScript editor, a newly-released cloud-based video production platform (including logging, clipping, editing, publishing and distribution tools) developed by Forbidden Technologies entirely in Java and converted to JavaScript with CheerpJ. The Blackbird JavaScript Editor will be announced at NAB, the world’s largest broadcasting trade show in Las Vegas, April 7 2018. More details can be found in Forbidden’s press release here.

We think that the release of an application like the Blackbird JavaScript Editor is not only a testament to the capabilities of CheerpJ, but also a milestone in the maturity of compile-to-JavaScript solutions available on the market.

Is CheerpJ optimised?

CheerpJ adopts many a optimisation to ensure great performance and minimal footprint in the converted application. These are the main ones:

  • Modularised Java 8 runtime. Only the required components of the runtime are downloaded, to minimise the total download footprint. A special debugging feature allows to track the methods originating the request of each runtime module, to allow further optimisations on the application side.
  • 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-code LLVM-based codegen optimisations. CheerpJ is a full compiler based on LLVM, and as such, it leverages all the full-code optimisations of the LLVM compiler stack.
  • Custom performance optimisations. CheerpJ implements a very wide range of specific performance optimisations, leveraging our 5 years of expertise in compile-to-JavaScript technologies.

Why is CheerpJ unique?

Compared to TeaVM, CheerpJ support 100% of the Java 8 SE runtime, as well as native reflection and dynamic class creation. TeaVM is a great technology, but its main purpose is not allowing legacy Java applications to be migrated to HTML5.

Compared to GWT, CheerpJ does not require access to the source code, does not require any modification to the Java source, and has full runtime support. Of course, GWT focus is on the development of new frontend applications, rather then on the migration of legacy ones.

Compared to JSweet, CheerpJ is a compiler, as such performing full-code optimisations, and generating unreadable JavaScript code. JSweet has partial JRE coverage and does not aim at allowing effortless conversion of Java applications to JavaScript.

Getting started and documentation

You are welcome to start using CheerpJ 1.0 immediately. We would invite both current and new users of CheerpJ to have a look at our getting started documentation page, since we have changed the URLs for the CheerpJ cloud runtime components.

We hope you will enjoy this release of CheerpJ, and we welcome your feedback. To report any issues, please use our issue tracker. For any question or comment, you are welcome to join the CheerpJ developer mailing list or reach us on Gitter.

Thank you!
Leaning Technologies

Want to know more?

For more information on CheerpJ and Leaning Technologies, visit our website at https://leaningtech.com.

Follow us on twitter (@leaningtech) and visit https://leaningtech.com to receive all our updates. For additional technical information on CheerpJ, please visit our Documentation page.