CheerpJ

Real Java, for the browser.

Version 5.0Discord serverGitHub issues
Java 8: OpenJDK 8u512Java 11: OpenJDK 11.0.33Java 17: OpenJDK 17.0.21Java 21: OpenJDK 21.0.13Java 25: OpenJDK 25.0.5, in preview

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>

Java applications, applets, JNLP apps and libraries run through CheerpJ, a WebAssembly JVM, in any modern browser

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:

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:

Terminal window
npx http-server -p 8080
  • cheerpjInit starts CheerpJ. Its options choose the Java version, the clipboard mode, networking and more.
  • cheerpjCreateDisplay creates the area of the page that holds the Java windows.
  • cheerpjRunJar runs the application, as java -jar does. For java -cp … com.example.Main, use cheerpjRunMain.
  • /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.
Use a web server
Open 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.
Get started

How CheerpJ works

  1. The page loads CheerpJ. One script tag loads the JVM and the OpenJDK class library, from the CheerpJ CDN or your own web server. cheerpjInit starts the runtime and chooses the Java version.
  2. 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.
  3. 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

JavaJava 8 (the default), 11, 17 and 21, with Java 25 in preview, chosen with the version option
LanguageThe whole Java language and bytecode, including reflection, proxy classes, custom class loaders and obfuscated code
ApplicationsDesktop applications, applets (Java 8), Java Web Start / JNLP applications, Oracle Forms and EBS, and libraries
UISwing and AWT, with multiple windows
FilesVirtual file systems on your web server, in browser storage and in memory; uploads and downloads
NetworkingHTTP and HTTPS through the browser; TCP and UDP through Tailscale
DesktopClipboard, printing and audio
Native codeNative methods in JavaScript or compiled to WebAssembly
BrowsersChrome, Edge, Firefox and Safari, on desktop and mobile
Not supportedJavaFX, 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:

Terminal window
npx skills add leaningtech/skills --skill cheerpj

Or 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

WhereBest for
DiscordQuestions, help getting started, and showing what you built
GitHub issuesBugs in CheerpJ or the browser extensions
Contact usLicensing, 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.

Build with Java for the browser.