CheerpJ 5.0 is out. Run Java 21 in the browser, with Java 25 in preview. Read the announcement

How CheerpJ works

CheerpJ is a Java Virtual Machine and a full build of OpenJDK for the browser, implemented in WebAssembly and JavaScript. It runs your compiled Java bytecode as it is, with no source code, recompilation, plug-in or local Java installation.

Move the Java runtime into the browser

A desktop Java application needs a Java runtime installed on every device. CheerpJ serves the runtime and the application as web files, and runs the existing bytecode in the browser.

Your Java files

JARs, classes, libraries and resources, as they are compiled now. No source code is needed.

CheerpJ

A JVM and the OpenJDK class library, served as static files from your web server or the CheerpJ CDN.

A modern browser

Chrome, Edge, Firefox or Safari, on desktop or mobile, with no plug-in and no local Java runtime.

The application and its backend stay as they are. Only the way the application reaches users changes.

The components behind CheerpJ

CheerpJ provides a Java runtime and the operating-system services a Java application expects, built on browser APIs.

Java runtime

A JVM written in C++ and compiled to WebAssembly and JavaScript, with the full OpenJDK class library of each supported Java version.

Window manager

Each AWT and Swing window is an HTML element with its own canvas, and frames and dialogs get an HTML title bar. Multiple windows and keyboard focus work as on the desktop.

File systems

Your web server, read over HTTP; persistent storage in the browser; and memory for data passed in from JavaScript. Read the file system guide.

Networking

HTTP and HTTPS through the browser’s own networking. TCP and UDP through Tailscale, a WireGuard VPN carried over WebSockets. Read the networking guide.

What happens when a user opens the application?

CheerpJ loads the runtime, reads the existing application files and runs the Java bytecode in the browser tab.

  1. The browser loads CheerpJ

    A script tag loads CheerpJ from your web server or the CheerpJ CDN. The page starts the runtime with cheerpjInit, which chooses the Java version, and the application with cheerpjRunJar or cheerpjRunMain. On Java 8, the page’s applet tags start on their own.

  2. CheerpJ loads the bytecode as it is needed

    The JARs are served from your web server. CheerpJ downloads the parts the application needs, as it needs them, in chunks with HTTP Range requests. The browser’s cache keeps them for the next visit.

  3. The interpreter runs the bytecode

    Execution starts in an interpreter, which also counts how often each part of the code runs.

  4. The JIT compiler optimises execution

    Code that runs often is compiled to JavaScript while the application runs. The compiler inlines and devirtualises calls, and the browser’s JavaScript engine runs the result.

  5. Browser APIs provide access

    The window manager draws the interface in the page. Files, network connections, the clipboard, printing and audio go through the browser’s APIs, inside its sandbox.

How Java runs in a browser tab

Two tiers of execution

Bytecode starts in an interpreter, and code that runs often is compiled to JavaScript. Your bytecode is not compiled ahead of time, and no part of CheerpJ runs on a server.

Threads

Java threads are scheduled by CheerpJ and take turns on one browser thread: the page’s own, or a Web Worker’s when CheerpJ is started in one.

Memory

Java objects are ordinary JavaScript objects, garbage-collected by the browser. Weak references and finalizers use the browser’s own mechanisms.

Native code

OpenJDK’s own native code is compiled to WebAssembly. The application’s native methods can be implemented in JavaScript or compiled to WebAssembly. Pre-built binaries, such as .dll and .so files, cannot run in a browser.

What happens to each part of the Java application?

CheerpJ provides a browser-based equivalent for each service a locally installed Java runtime gives an application. The compatibility page lists what is supported in detail.

Java application component How CheerpJ handles it
Java bytecode Run unchanged by the CheerpJ JVM: interpreted first, then compiled to JavaScript where it runs often
Java standard library The full OpenJDK class library of the chosen Java version, with OpenJDK’s native code compiled to WebAssembly
Swing and AWT interfaces Drawn by the window manager with HTML elements and canvases
JARs and dependencies Read from your server as they are, including third-party libraries, obfuscated code and classes loaded by custom class loaders
Files Virtual file systems: your server over HTTP, browser storage and memory. Local files enter as uploads and leave as downloads
HTTP and HTTPS Through the browser’s networking, under its security model. Services on another domain must allow cross-origin requests
TCP and UDP Through Tailscale, with a control server you can host yourself
Clipboard, printing and audio An internal clipboard by default, with the system clipboard as an option; printing through the browser’s print dialog; audio through the Web Audio API
External processes Runtime.exec does not start a process. A JavaScript function you supply can handle the command instead
JavaScript integration Java calls JavaScript through native methods, and JavaScript uses Java classes in library mode. See interoperability
Native libraries Implemented in JavaScript or compiled to WebAssembly. Pre-built .dll and .so files cannot run

Browser-based execution, not remote application streaming

CheerpJ runs the Java application on the user’s device, inside the browser. There is no remote desktop or streaming session for each user.

Client-side execution

Java code runs in the user’s browser, not on an application server.

Static deployment

The runtime and the JARs are static files on any web server or CDN. There is no server-side process, API or database.

Existing backends

The application keeps using its APIs and services, subject to browser policies and networking configuration.

Central updates

Files are updated on the server, not on every device. Self-hosted deployments never update automatically.

Deployment covers the server and browser requirements, and the comparison sets CheerpJ against remote sessions and rewrites.

Run Java within the browser sandbox

Java code has no direct access to the operating system. It reaches files and the network only through the CheerpJ runtime and the browser, under the same rules as any web page.

Remove legacy client dependencies

  • No locally installed Java runtime
  • No Java plug-in, Internet Explorer or IE mode
  • No installer, local service or admin rights
  • No connection to Leaning Technologies when self-hosted: the licence is checked in the browser

What stays with you

  • Application security, hosting and authentication
  • Backend services and access controls
  • Browser and extension policy

The security page describes the model in detail.

Designed for real enterprise Java applications

CheerpJ 5.0 supports Java 8, 11, 17 and 21, with Java 25 in preview, and runs these kinds of application.

Desktop applications

Swing and AWT applications, run from their JAR files.

Java applets

On Java 8, through CheerpJ Core on your own pages, or the Applet Runner on pages you do not control.

Java Web Start

JNLP applications through the JNLP Runner, on Java 8, or with CheerpJ Core, by running the JARs the JNLP file lists.

Oracle Forms and EBS

Forms 6i, 10g, 11g and 12c applications, and the Forms-based parts of Oracle E-Business Suite, without desktop Java. See Oracle Forms.

Java libraries

Java classes, objects and arrays used from JavaScript in a web application, in library mode.

Test the actual application

Compatibility depends on the APIs, native libraries, network protocols and operating-system integrations an application uses. The compatibility page lists them.

Choose the right delivery model

Integrate CheerpJ into a web application, or use a browser extension for existing applets and Java Web Start applications.

Integrate CheerpJ into a web application

Add CheerpJ to a web page, and start an application or library with its JavaScript API, or run the page’s applets. Your team controls the page, authentication, deployment and integration with other web components.

About CheerpJ Core

Use a CheerpJ browser extension

The Applet Runner and JNLP Runner run existing applets and Java Web Start applications in Chrome and Edge, without changes to the page. IT can force-install them by Group Policy.

Explore the extensions

Build with Java for the browser.