APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

SwingJS: EJS Java to JavaScript Conversion Examples Documents

Main Document

SwingJS: EJS Java to JavaScript Conversion Examples 

written by Wolfgang Christian and Robert Hanson

It was believed that the entire enterprise that had grown around embedding Java simulations in web pages had come to an end when the Java applet plugin was removed from browsers in 2018.   Fortunately, work done at St. Olaf College now makes it possible to convert (transpile) Java programs (both stand alone programs and applets) to JavaScript.  Here we present examples of how this technology can be used to convert Java code generated by the Easy Java Simulations modeling and authoring tool.

The examples presented here were not recoded in JavaScript.  The simulation's Java code is created using EJS and copied into the Eclipse Java development workspace where it is transpiled into JavaScript. In the end, the original functional of the Java program is virtually identical to its JavaScript counterpart, with all the layout, events, and functionality of the original.

The SwingJS transpiler developers maintain a GitHub repository for Java developers who want to convert their Java applets or Java applications to JavaScript, allowing continued, simultaneous one-source development of both Java and JavaScript.

Last Modified August 12, 2020

OSP Projects:
Open Source Physics - EJS Modeling
Physlet Physics
Physlet Quantum Physics
STP Book