CheerpJ - Frequently Asked Questions
Updated on September 2017

What is CheerpJ?

CheerpJ is a solution for enabling the development of client-side Web applications starting from existing, unmodified Java applications. CheerpJ consists of an ahead-of-time compiler from Java bytecode to JavaScript, of a full Java runtime environment in JavaScript, and of a on-the-fly compiler for dynamic class generation, to be deployed alongside the application.

What does the CheerpJ compiler do?

The CheerpJ compiler, based on LLVM/Clang, as well as on parts of Cheerp, converts Java bytecode into JavaScript, without requiring the Java source. CheerpJ can be invoked on whole Java archives (.jar) or on single .class files, and generates a .jar.js (or .js) output.

How does CheerpJ support reflection?

In order to support reflection, CheerpJ, similarly to a JVM, utilizes the metadata available in the original .jar file. A converted application, to be deployed on a web server, comprises both the converted .jar.js JavaScript files and the .jar archives. After having converted a .jar archive, it is possible to remove all the bytecode from them prior to deployment, in order to minimize download time (we provide a simple tool to do so). The combined size of the pruned .jar archive and the output JavaScript, after compression, is comparable to the original .jar (anecdotally, we have seen an average overhead of 20% or less). Optionally, .jar archives can be split into multiple segments (size to be defined at compile time) before being deployed. The application will only load the required segments at run time, thus further reducing download time.

How does CheerpJ support dynamic class generation?

One component of CheerpJ is the CheerpJ on-the-fly compiler (CheerpJ.js), a minimalistic Java-bytecode-to-JavaScript compiler written in C++ and compiled to JavaScript. CheerpJ.js needs to be distributed alongside any converted Java application that makes use of dynamic constructs such as proxy classes, which get compiled on the fly at run time directly on the browser.

What parts of the Java SE runtime are supported?

The CheerpJ runtime environment is a full Java SE runtime in JavaScript. Differently from other technologies which provide a partial re-implementation written manually in JavaScript, we opted to convert the entire OpenJDK Java SE runtime to JavaScript using CheerpJ. The CheerpJ runtime is constituted of both JavaScript files and .jar archives. All CheerpJ runtime components are dynamically downloaded on demand by the application to minimise total download size. The CheerpJ runtime library is hosted by us on a dedicated CDN-backed domain, and we invite users to link to it in order to take advantage of caching and cross-application resource sharing.

Can I use CheerpJ to convert my legacy Java application? I have no longer access to the source code.

Yes, you can convert any Java SE application with CheerpJ without touching the source code. You only need all the .jar archives of your application.

Can I use CheerpJ to convert Java libraries and integrate them in my HTML5 application?

Yes. Java methods can be exposed to JavaScript with an asynchronous interface. A synchronous-looking construct is provided to minimise verbosity when multiple methods are invoked. An example can be found here

Can I call JavaScript libraries or web APIs from Java?

Yes, CheerpJ allows you to interoperate with any JavaScript or browser API.

What is the size of the output of CheerpJ

The combined size of the .jar to be served (pruned of its bytecode) and of the resulting JavaScript is similar to that of the original .jar archive. Anecdotally, an overhead of 20% seems to be the average.

Can JavaScript code produced by Cheerp be plugged into Node.js?

Yes, it should. However, this has not been one of our areas of focus so far.

What is the status of CheerpJ?

CheerpJ is currently in a public beta stage. CheerpJ can be freely downloaded and used for non-commercial and technology evaluation purposes. For commercial applications, please get in touch at General availability of CheerpJ is expected in November 2017.