A JVM written in TypeScript that runs Java 25 class files and JARs in the browser and under Node. It runs the real OpenJDK 25 class library unmodified, and its page API matches CheerpJ's, so existing pages can switch.
pnpm add @project516/java-webServe node_modules/@project516/java-web/dist/ as static files (on a GitHub
Pages project site, /app/ is the site root user.github.io, so the page's
files are under /app/<repo>/), then:
<script src="java-web.js"></script>
<pre id="console"></pre>
<script type="module">
await cheerpjInit();
await cheerpjRunJar("/app/my-app.jar"); // /app/ is the web server root
</script>cheerpjRunMain, cheerpjRunLibrary (call Java from JS), JS natives and
/files/ storage work too. See docs/browser.md.
npx @project516/java-web -cp classes Main # or: npx @project516/java-web -jar app.jarimport { runNode } from "@project516/java-web";
const code = await runNode({ classpath: ["classes"], mainClass: "Main" });See docs/node.md. To debug a program with jdb or an IDE, see docs/debugging.md.
- Console apps, libraries and javac: every Java SE module, plus
jdk.compiler,jdk.httpserverand a few more. - The headless parts of
java.desktop, includingGraphics2Don aBufferedImage, with HotSpot's pixels except for text. - Sockets: real ones under Node; in the browser, loopback inside the VM and
http:/https:throughfetch. - Child processes under Node, through the host's own programs.
- Not yet: AWT and Swing windows, child processes in the browser, IPv6.
Details: docs/support.md.
CheerpJ 5.0 takes the same page calls (cheerpjInit,
cheerpjRunMain), so the two can be compared on one page. The table gives
medians of 10 runs, measured 2026-12-03 in headless Chrome 158 on a 4-core x64
Linux machine. java-web was built from master at 08b233f, and CheerpJ 5.0
loaded from its CDN with version: 25. Cold means an empty browser cache, and
warm means a reload of the same page. Downloads count the runtime and JDK
only, not the program's own jar. The javac row compiles 26 small programs
(2,135 lines) through javax.tools. The npm release, 0.1.3, takes 1.3 s for
hello world and 19.2 s for javac, both cold.
| java-web master | CheerpJ 5.0 | |
|---|---|---|
| Java 25 | yes | preview |
| Hello world, cold | 1.1 s, 2.6 MB | 5.6 s, 11.3 MB |
| Hello world, warm | 0.5 s | 2.5 s |
| javac, cold | 17.1 s, 13.8 MB | 21.2 s, 19.3 MB |
| javac, warm | 16.1 s | 16.8 s |
| AWT and Swing windows | not yet | yes |
| License | AGPL-3.0 | free for personal, educational, hobby and evaluation use, one-person companies and non-commercial open source, with a credit and loaded from CheerpJ's CDN; business use needs a licence |
CheerpJ 5.0's experimental WasmGC engine (wasmGC: true) stopped with an
"illegal cast" error before it ran any Java, on Java 25 and on Java 21, so the
table uses its default engine.
CheerpJ also runs Java 8, 11, 17 and 21, applets and JNLP; java-web runs only Java 25.
You need Node 23.6+, pnpm, curl and bzip2 on Linux or macOS.
pnpm install
pnpm jdk # downloads the pinned JDK 25 and builds the image
pnpm test # compares programs against HotSpot
pnpm build # builds dist/More: docs/development.md.
AGPL-3.0-only. The OpenJDK class library is GPL-2.0 with the Classpath
Exception, and the bundled DejaVu Sans font has its own license; both notices
ship in dist/jdk/legal/.