Run a Java applet
Run a java applet in modern browsers
CheerpJ can run Java applets in the browser seamlessly. This page will help you getting started with CheerpJ for Java applets using the CheerpJ runtime environment on your own webpage.
Check out our browser extension for running Java Applets while you browse in modern browsers.
Running your own applet
You will need:
- Your applet file(s)
- The HTML file where your applet is meant to be displayed.
- A basic HTTP server to test locally
1. Integrating CheerpJ in your HTML file
This tutorial assumes you already have an HTML file with an <applet>
, <object>
or <embed>
tag.
In order to integrate CheerpJ, you just need to add:
- A simple
<script>
within the<head>
of your page with the CheerpJ runtime loader.
- A second script calling
cheerpjInit()
to initialize CheerpJ’s runtime environment.
For example:
2. Host your page locally
You can now serve this web page on a simple HTTP server, such as the http-server utility.
In case your users have a native Java plugin installed, you can replace the original HTML tag with a
cheerpj-
prefixed version.<cheerpj-applet>
,<cheerpj-object>
, and<cheerpj-embed>
are all supported.
The result
You will see the CheerpJ display on your browser with some loading messages before showing your applet running. Depending on your application and the optimizations applied, this could take just a few seconds.