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.

EJS 5 and HTML 5 post and replies

Return to the EJS 5 and HTML 5 thread
Login to post to this thread

How to export at HTML 5?
Nick Gross
17 Posts

I am working with a group of physics teachers and we are programming simulations using EJS.
I had them work with EJS 5 under the assumption that we could output HTML 5.  But I can not figure out how that works.  Can anyone point me in the right direction?
Thanks,
Nick Gross


Replies to How to export at HTML 5?

Re: How to export at HTML 5? -
Francisco Esquembre
237 Posts

Hi Nick,

Unfortunately, you cannot write your code using the Java 'flavour' of EjsS and then automatically generate the HTML version, which requires Javascript and HTML view elements. This is not so simple. You need to use the Javascript 'flavour' of EjsS to create your simulation from the start, instead.

The good news is that your previous knowledge with EJS helps A LOT with the new flavour. The Model part looks very much the same. (The main change is that Javascript has no typed variables. - no 'int', 'double', etc. All variables are just 'var'. Still, EjsS lets you select what type it should have, for convenience when connecting to view properties.) Algorithms look very much the same.

The View is a little bit more different, because not all view elements exist. But we tried our best to offer similar elements. I think you can easily get up and running by copying and pasting from existing Javacript+HTML examples.

Myself, whenever I want to port an existing Java simulation to the new Javascript+HTML flavour, I  open the Java and the Javascript flavoured versions of EjsS side by side. The Java with the existing simulation, and the Javascript empty, and then copy or retype as much as possible. This works fine for the Model.

For the View, I typically start copying another existing Javascript example with a view similar to what I want to create.

It takes me sort of an hour, or less, but the result RUNS ON MY TABLET!

Hope this helps.

Paco



Re: Re: How to export at HTML 5? -
Nick Gross
17 Posts

Francisco,
Thanks so much for your reply.  
I am still confused though.  What do you mean by the EjsS?  I don't see the download for that on the download page.

http://www.um.es/fem/EjsWiki/Main/Download

Everything else you say makes perfect sense, I just need a starting point.
Thanks
Nick



Re: How to export at HTML 5? -
Francisco Esquembre
237 Posts

Nick,

EjsS is the new acronym for the good old boy EJS. Below is what I wrote in the Wiki main page. If you don't want to read it, the short version is that EjsS 5.0 is the new EJS.

Paco

Easy Java/Javascript Simulations, also known as EjsS (and, formerly, EJS or Ejs), is a free authoring tool written in Java that helps non-programmers create interactive simulations in Java or Javascript, mainly for teaching or learning purposes. EjsS has been created by Francisco Esquembre and is part of the Open Source Physics project.

A brief historical and naming remark: Before release 5.0, EjsS could only create Java simulations. Hence, its former name was "Easy Java Simulations" and its acronym just "EJS". Now, since release 5.0, EjsS can create (also) simulations that use Javascript and HTML5, and hence can be run on tablets and smartphones (see our Reader App). This major change explains why we have renamed EJS as Easy Java/Javascript Simulations, and its acronym is EjsS. You may still find many references to EjsS (even in this wiki) that use its old name.



Re: Re: How to export at HTML 5? -
Nick Gross
17 Posts

Francisco,
Thanks again for your reply.

So if I have EJS 5.0 (which I do) and I export an web version, (which I have tried but struggled with) I should be able to run it with out a security issue and on an iPad?

Nick



Re: Re: Re: How to export at HTML 5? -
Francisco Esquembre
237 Posts

Nick,

Make sure that, in the "Advanced options" tab of the EJS Console (not EJS, but its Console), you choose the "Programming language" to be "Javascript".

Then run EJS (or EjsS :-) ) and create a simulation with it. The simulation you export will be a purely Javascript+HTML one, so it runs on tablets.

To run on a tablet, you can either:

- Serve the simulation HTML page from a Web server, and then open the page (from the server) using the tablet browser.

- Use our EjsS Reader App. We now have ready the Android version of it. But the iPad version will be available in days (so we hope). See http://www.um.es/fem/EjsWiki/Main/ReaderApp

Paco



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