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.
There are two different ways to run a Java Applet in the browser:
- Running your own Java applet using the CheerpJ runtime environment in your own webpage.
- Running a public applet using the CheerpJ Applet Runner Chrome extension for applets integrated with the applet tag
<applet>
on public websites.
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.
Running a public applet
1. Install the CheerpJ applet runner
CheerpJ Applet Runner is available for Chrome and Edge.
2. Go to a website with an applet
Visit a page with a Java applet, such as this one and click on the CheerpJ Applet Runner icon in the toolbar and enable CheerpJ.
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.