Options for running Java versions more recent than Java 8
I'm a doctoral researcher, and part of my tasks is providing technical support for grading student projects for a Java course.
I won't get into the details, and instead just state my goal: I would like students and teaching assistants to be able to run student projects in the browser.
The issue I am running into is that we target source level 21, so CheerpJ rejects the JAR outright. For educational reasons we don't want to lower this to 8, even though 99% of code should be compatible with 8.
So, my question: what are my options here?
Are there experimental builds supporting Java 21 (or 17)?
Is there a way to compile newer bytecode to an older version?
Thanks in advance!
3 Replies
Currently CheerpJ only supports Java 8, but the architecture is designed to support more modern versions of Java as well
Support for Java 11 is coming later in the year, after the summer most likely
Depending on the complexity of Java 11 support we might managed to support Java 17 in the same release, but that is a stretch goal.
We do not have experimental builds to share at this time
What you want to achieve is 100% possible, but it will need a few more months
The timeline might be accelerated if a commercial user decides to sponsor the effort to support modern Java. In that case we will be able to dedicate more resources to the project.
I'm trying to instead compile my code to Java 8 with
javac -source 1.8 -target 1.8
. The code compiles fine, but when trying to run it with CheerpJ, it still says "Uncaught (in promise) CheerpJ only supports Java 8 at this time."We recommend compiling with
javac
from JDK8
I am unsure about what is the precise semantics of -target 1.8
, it's likely that is not the same
CheerpJ is internally checking the actual version of the .class file
Also, keep in mind that you need to compile all classes for Java 8, you might have dependencies which are not compiled with the correct command line
In any case, using JDK8 is the safest option