Events Step by Step

Experimentation

Compiling and Running the Model

   
 

Now that all necessary classes are implemented, you need to compile them in order to be able to run the model. In case you did not succeed with implementing the classes on your own, you may download the complete source code of the EventsExample model. Of course you will also need the DESMO-J framework, so if you haven't downloaded it yet now is the time to do so. Make sure you add the desmoj-2.5.1c-bin.jar file (or a different distribution you have chooen) as a library to your IDE or - if you don't use an IDE - place it in the same directory as your source files.

Compiling and running the model is easiest from inside an IDE. If you don't use an IDE, follow these steps:

  1. In a command shell, change into the directory where your source files (and the desmoj-2.5.1c-bin.jar file) are located.
  2. Invoke the java compiler by issuing the command
    javac -cp desmoj-2.5.1c-bin.jar; *.java (Windows environment) or
    javac -cp desmoj-2.5.1c-bin.jar: *.java (Linux environment).
  3. If the compiler generates any error messages, return to your editor and correct the syntax errors. Save the modified file(s) and try compiling them again. Repeat this procedure until compilation is successful.
  4. Run the model by issuing the command
    java -cp desmoj-2.5.1c-bin.jar; EventsExample (Windows environment) or
    java -cp desmoj-2.5.1c-bin.jar: EventsExample (Linux environment).

With or without IDE, running the model will produce output to the shell. You will see the following start-up message:


EventsExampleExperiment starts at simulation time 0.0
 ...please wait...

If you've set the experiment to show a progress bar (via exp.setShowProgressBar(true);) then a progress bar window will pop up. Note that you'll have to close this window manually after the simulation stops to really stop execution of the model.

The progress bar window

The execution stops quite unspectacularly with the message:


EventsExampleExperiment stopped at simulation time 1500.0



   
  http://desmoj.sourceforge.net/tutorial/events/exp0.html