SnapCode is free and uses the CheerpJ browser JVM to run real Java in the browser. CheerpJ is moving quickly this year to support the latest versions of Java. Java 11 this month, Java 17 this summer, and hopefully release parity soon after.
SnapCode: https://reportmill.com/SnapCode/
CheerpJ: https://labs.leaningtech.com/blog/cheerpj-4.0