cincheo / applet-migration-example

How to migrate and modernize a Java applet to HTML5
http://www.cincheo.fr
22 stars 9 forks source link

Migrating a Java Applet to HTML5

This project is a proof or concept demonstrating that it is possible to migrate an existing Java Applet to a true HTML5 application. The migrated applet is a simple calculator applet that was found on the Internet.

Why?

Soon, Java Applets will be deprecated (read the official post from Oracle) and Chrome does not support applets anymore.

Applets can be migrated to Java WebStart applications, but they would still relies on outdated technology and users may hit many accessibility and maintenabilty issues.

Here, we show that it is possible to run an applet in any browser as a pure JavaScript program. We even show that it is possible to truly modernize it by taking advantage of available JavaScript libraries.

How does it work?

We use JSweet and the J4TS library to transpile the Java code to JavaScript code. For each class or method of the Applet/AWT API used by the calculator program, we provide an implementation in JSweet (i.e. in JavaScript but with the Java language). Nowadays, most Java APIs have a JavaScript counterpart, so it would be possible to provide an implementation for most Java libaries by wrapping existing JavaScript librairies.

This migration technique has several advantages:

For more details, check out the video.

How to launch

Just clone the project and open the applet version you want to try with your favorite browser.

How to build

You need to have Node.js and Maven installed.

> mvn clean generate-sources