Child pages
  • Running the Built-in Examples
Skip to end of metadata
Go to start of metadata

JAS3 has a number of built-in example programs that show how to use the AIDA interfaces. They are currently available in three languages:

  • Java compiled code
  • Pnuts scripting language
  • Jython scripting language

To run the examples start JAS3, and from the welcome page follow the examples link. (If the welcome page is not automatically displayed use the icon to display it).

From the examples page you can select the language you prefer.

Pnuts and Jython

Follow the Pnuts Example link to get to the list of examples (the following instructions also apply to Jython)

Choose one of the examples from the above list (in the picture below we chose CreateAndPlotHistograms.pnut).

Running the Pnuts or Jython examples is very straightforward: either use the File, Run menu item or use the Run item in the editor's popup menu, or just use the F2 key.

Each time you run a script a new Pnuts or Jython interpreter a console window is created. Once the script has completed you can type additional commands into the console to interrogate or operate on the objects created by the script. (You can also create a new interpreter console without first running a script by using the File, New, Pnuts Console or Jython Console menu item.).


Running the Java examples is very similar to running the Pnuts or Jython scripts. As before you click on the file to open it in the editor, but in the case of Java you have to compile the code before you can run it. To compile a Java example use the File, Compile menu item or right click on the script and then select Compile or just use the F9 key.

One thing worth mentioning is that the examples are pure AIDA. This means that they do not depend in anyway on JAS3, you can use the exact same code outside of JAS3 provided you have set up your AIDA environment correctly.

Why do we support both scripting and Java when the examples look very similar and have basically the same functionality? The compiled Java code is more efficient that the equivalent script, it runs perhaps 10x faster. But the scripts are more suitable for experimenting with the AIDA objects, since you can type commands and see the results immediately. Fortunately any Java object can be easily manipulated from the scripting language, so we expect people to use some combination of the two, with the stable, time-critical components implemented in Java and the experimental parts in Pnuts. In the future we hope to support automatic translation from Pnuts -> Java to make the transition from Pnuts to Java easier.

  • No labels