What is CheerpJ?
What does the CheerpJ compiler do?
What parts of the Java SE runtime are supported?
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?
How does CheerpJ support reflection?
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?
What is the size of the output of CheerpJ
The size of the output is too big! Why doesn’t CheerpJ remove “dead code”?
In Java there is no “dead code”. Java supports reflection, so all code and classes can be potentially used at runtime. For this reason CheerpJ cannot automatically remove any code.
This said, depending on the application, it is often possible to remove a lot of code using ProGuard: an industry standard open source tool. CheerpJ provides support to automatically generate a ProGuard configuration file to make sure that classes used via reflection are not removed. For more information see: here
Yes, it should. However, this has not been one of our areas of focus so far.
When compiling my application I see the message
Failure compiling MyFile.class, but cheerpjfy continues to execute with no errors
This means that it was not possible to use the new codegen. CheerpJ will use, for this class, the legacy codegen. This might happen for multiple classes in the same .jar,
My Java application needs to get data over the network, but I only get
In the browser environment it is not possible to use sockets to connect to arbitrary ports. As a special exception CheerpJ provides a custom HTTP/HTTPS handler (based on XHR) that can be used to get data over HTTP and use REST APIs. To enable this handler please set the property
java.protocol.handler.pkgs=com.leaningtech.handlers during the
cheerpjInit call, for example:
Please note that when using CheerpJ to run applets the custom handlers are enabled by default.
When I run an application compiled with CheerpJ I see 404 errors in the browser console. What’s going on?
Ignore those errors. CheerpJ provides a filesystem implementation on top of HTTP. In this context it is absolutely ok for some files to be missing. CheerpJ will correctly interpret 404 errors as a file not found condition.
My application compiled with CheerpJ does not work and I just see the “CheerpJ runtime ready” on the top of the screen. What’s going on?
Many first time users get stuck at this point. The most common issues are:
- Opening the HTML page directly from disk: The URL in the browser should always start with http:// or https://, if it starts with file:// CheerpJ will not work. You need to use a local web server during testing.
- Forgetting to add “/app/” prefix to the JAR files used in Web page. CheerpJ implements a virtual filesystem with multiple mount points, the “/app/” prefix is required.
- More in general, you can use the “Network tab” of the developer tools in the browser to check if the JAR is being correctly downloaded. If the JAR is never downloaded, or a 404 error is returned, something is wrong with the JAR path. If you don’t see anything in the “Network tab”, please reload the page while keeping the developer tools open.
- When converting obfuscated JARs on MacOS and Windows there might be collisions between classes due to the case-insensitive nature of the filesystem. For example
A.classwill be considered the same. Always try to convert the JAR using a Linux machine before reporting a bug when converting obfuscated JARs.
My application compiled with CheerpJ does not work and I see a cross origin error to a Google service in the console. What’s going on?
The cross origin message you see happens as part of our automatic bug reporting system and it is not the real error. Something else is making your application crash, please report a bug here.
Can I play Old School RuneScape using CheerpJ or the CheerpJ Applet Runner extension?
Not yet. The main problem is that RuneScape requires low level network connections primitives (sockets) which are not provided by browsers at this time due to security concerns. In the future we might provide a paid add-on to the CheerpJ Applet Runner extension to support this use case via tunneling.
CheerpJ cannot be used to generate WebAssembly code at the moment.
What is the status of CheerpJ?