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.

Debugging EJS simulations in Eclipse post and replies

Return to the Debugging EJS simulations in Eclipse thread
Login to post to this thread

PDF describing how to debug EJS simulations
Larry Engelhardt
17 Posts

The attached document gives step-by-step instructions for opening an EJS simulations in Eclipse for debugging.

Attached File: EclipseDebugging.pdf

Replies to PDF describing how to debug EJS simulations

Re: PDF describing how to debug EJS simulations -
lookang Avatar
222 Posts

Hi Larry Engelhardt!
chance to make a similar video to Ejs introduction that talks about the debug EJS simulations?

i tried to follow the PDF instructions but i have never used eclipse before  thus, beginners like myself face a challenge following the PDF.
look forward to more video tutorials on Ejs soon :)

great video
Getting started with EJS, an excellent tutorial by Larry Engelhardt. http://swampfox.fmarion.edu/sites/swampfox.fmarion.edu.engelhardt/files/pdfs/EJS_Tutorial/EJS_Tutorial.html by Francis Marion University Larry Engelhardt
mirror here http://www.compadre.org/osp/items/detail.cfm?ID=10316

i have a blog post http://weelookang.blogspot.com/2011/02/easy-java-simulation-tutorial.html to anyone interested to learn Ejs.

Post edited November 2, 2011 at 10:50 AM EST.

OSP@SG blog
OSP@SG Digital Library

Re: PDF describing how to debug EJS simulations -
Pablo Dominguez-Garcia
2 Posts

Hi there,

I have followed those steps for debbuging EJS programs with Eclipse and my project compiles and works fine. Thanks!

Now I would like to know how to run the numerical evolution of the equations (when you push the "play" button in a EJS simulation) but without any graphical interface (using the command line and saving automatically the results of the temporal evolution in a data file). Does anyone know how to run only the "simulation" by itself without all the graphic environment?

Thank you in advance!


Post edited January 16, 2012 at 8:51 AM EST.

Re: Re: PDF describing how to debug EJS simulations -
Francisco Esquembre
228 Posts


EJS generates code that extends basic Java classes which send the order to the view to update itself automatically.

If you are of the hacker type :-) go and see the org.colos.ejs.library.Animation.java class and inspect the methods update() and step() there.

But there is another way of doing what you want (if I understood it well) for mortals. I'd recommend the following procedure.

There is a predefined method that allows you to prevent EJS to update the view: _setUpdateView(boolean _update)

By calling _setUpdateView(false), the simulation will run the model, but the view will not be affected by changes in it... until you call _setUpdateView(true).

Some people use this trick to let the model run very quickly until meeting a given condition, without waiting for the view for the lengthy process of updating itself every time.

One more thing... trails and traces will get ALL the values generated by the model, if only they will only display them when the UpdateView is set to true again.

Hope this helps.


Re: Re: Re: PDF describing how to debug EJS simulations -
Pablo Dominguez-Garcia
2 Posts

Thank you Francisco for your answer.

Yes, maybe I am of the hacker type. Mmm.. no, not really ;)

Ok, let's try some code. I have done this:

public class Principal{

public static void main(String[] args) {

particulas_v11 p = new particulas_v11(null,null,null,null,(String[])null,false);

Simulation sim = p.getSimulation();

//Does not work

for (int i=0;  i<1000; i++)


If I execute that, appears my EJS "simulation" and the simulation begins and stops when the for loop ends.

What I want to do is that, but without the limitation of the FPS and without any graphical interface. I would like to run the "simulation" in a remote computer, for example.  This would be very useful for doing systematic measurements by varying the input data of the "simulation".

Thanks again,


Post edited January 16, 2012 at 1:18 PM EST.

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