CheerpJ
Real Java, for the browser.
CheerpJ is a Java Virtual Machine and a full build of OpenJDK for the browser, implemented in WebAssembly and JavaScript. It runs Java 8, 11, 17 and 21, with Java 25 in preview: applications, applets, Java Web Start applications and libraries, from their compiled JARs, with no source code, recompilation, plug-in or local Java installation.
<script src="https://cjrtnc.leaningtech.com/5.0/loader.js"></script>
Choose your path
Each getting started guide takes one kind of Java program from its JARs to a running page:
- Application: a desktop Swing, AWT or console application
- Applet: an applet on a page you control, on Java 8
- Library: Java classes called from JavaScript or TypeScript
- Java Web Start: an application launched from a JNLP file
To run Oracle Forms or Oracle E-Business Suite, see Oracle Forms and Oracle EBS
on cheerpj.com.
Quick start
You need your JAR files, an HTML page and a web server. Put the JAR in a folder with this index.html:
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <script src="https://cjrtnc.leaningtech.com/5.0/loader.js"></script> </head> <body> <script type="module"> await cheerpjInit(); cheerpjCreateDisplay(800, 600); await cheerpjRunJar("/app/my_application.jar"); </script> </body></html>Serve the folder and open http://localhost:8080:
npx http-server -p 8080cheerpjInitstarts CheerpJ. Its options choose the Java version, the clipboard mode, networking and more.cheerpjCreateDisplaycreates the area of the page that holds the Java windows.cheerpjRunJarruns the application, asjava -jardoes. Forjava -cp … com.example.Main, usecheerpjRunMain./app/is the root of the web server the page comes from, as Java sees it. Forgetting the/app/prefix is the most common first mistake.
Get startedUse a web serverOpen the page over http:// or https://, never file://. The server must support HTTP Range requests, which Python’s http.server does not. See server setup.
How CheerpJ works
- The page loads CheerpJ. One script tag loads the JVM and the OpenJDK class library, from the CheerpJ CDN or your own web server.
cheerpjInitstarts the runtime and chooses the Java version. - CheerpJ runs your bytecode as it is. The JARs are read from your web server, in chunks, as the application needs them. An interpreter starts running the bytecode, and a JIT compiler turns the code that runs most often into optimised JavaScript.
- The application runs in the browser tab. A window manager draws Swing and AWT windows with HTML elements and canvases. Files, networking, the clipboard, printing and audio go through browser APIs, inside the browser sandbox.
Nothing runs on a server: CheerpJ is a set of static files, and the application runs on the user’s own device. Architecture explains each part, and How CheerpJ works gives the overview.
What CheerpJ supports
| Java | Java 8 (the default), 11, 17 and 21, with Java 25 in preview, chosen with the version option |
| Language | The whole Java language and bytecode, including reflection, proxy classes, custom class loaders and obfuscated code |
| Applications | Desktop applications, applets (Java 8), Java Web Start / JNLP applications, Oracle Forms and EBS, and libraries |
| UI | Swing and AWT, with multiple windows |
| Files | Virtual file systems on your web server, in browser storage and in memory; uploads and downloads |
| Networking | HTTP and HTTPS through the browser; TCP and UDP through Tailscale |
| Desktop | Clipboard, printing and audio |
| Native code | Native methods in JavaScript or compiled to WebAssembly |
| Browsers | Chrome, Edge, Firefox and Safari, on desktop and mobile |
| Not supported | JavaFX, SWT, and pre-built native binaries (.dll, .so, .dylib) |
The compatibility page has the full tables, including minimum browser versions.
Try it
Write and run Java in the browser with JavaFiddle, which is built on CheerpJ:
More to try, with nothing to install:
- Browsercraft
: the original Minecraft 1.2.5 client, running unmodified in a browser tab
- Showcase
: projects built with CheerpJ, such as FlatLaf, PhET simulations, ImageJ.js and Logisim
- Tutorials: complete examples, with their source in the cheerpj-meta repository
Not a developer?
The CheerpJ browser extensions run existing applets and Java Web Start applications in Chrome and Edge, with no changes to the page and no Java installation. They need no technical knowledge to install, and IT departments can deploy them with Group Policy. See CheerpJ extensions.
Using a coding agent?
Install the CheerpJ skill. It covers converting
java command lines, JARs, applets, JNLP files, Oracle Forms and libraries, and the common errors:
npx skills add leaningtech/skills --skill cheerpjOr point your agent at cheerpj.com/agents.md or cheerpj.com/llms.txt
.
Licensing
CheerpJ is free for personal, educational and hobby use, and for technical evaluation by organisations of any size. One-person companies and non-commercial open-source projects can use it for free with a “Built with CheerpJ” credit. Business use needs a licence. See licensing for a summary and examples, and cheerpj.com/licensing for the full terms and prices.
Getting help
| Where | Best for |
|---|---|
| Discord | Questions, help getting started, and showing what you built |
| GitHub issues | Bugs in CheerpJ or the browser extensions |
| Contact us | Licensing, commercial support and enterprise deployments |
Before you report a bug, read debugging CheerpJ and the FAQ. A good report names the CheerpJ version (from the loader URL), the Java version passed to cheerpjInit, your browser and operating system, and includes the full browser console output.
Community
CheerpJ has been in production since 2017. Over a million people ran a CheerpJ application in the last 12 months, and the CheerpJ browser extensions have more than 170,000 users. It is used by NASA, Ticketmaster, Moody’s, ADP and many other organisations.
The CheerpJ team and community answer questions on Discord, where you can also share your projects.