Scripts are programs, which are written in a scripting language. Scripts are mostly written in form of source files. So it is possible to edit the program very easy by changing the source file. Scripts can be used in jBEAM to automate processes and evaluations. Each script corresponds to a code snippet, which works directly on the jBEAM classes and can change all instances of jBEAM during runtime. By scripting languages Groovy and BeanShell scripts are pretty much those Java code, because the syntax is the same.

Scripting languages

Using jBEAM the developer can choose between two scripting languages, BeanShell or Groovy. BeanShell is suitable for smaller scripts in contrast to Groovy which is qualified for larger and professionally scripts. The file extension of the script files depends on the used language (BeanShell “bsh”, Groovy “groovy”). To use these technologies required libraries has to make available in jBEAM. The preferred scripting language can be defined in the jBEAM preferences (Edit -> Preferences) The NetBeans developing solution provided by SUN is the prime solution for developing, testing and debugging complex script files. The required libraries relevant for testing are a full version of jBEAM. The jBEAM JAVADOC provides a proficient survey of all methods in jBEAM.

Currently jBEAM supports two scripting languages:

  • BeanShell
  • Groovy


The syntax of a BeanShell is equal to Java 1.4, i.e. Java 1.4 source codes should run without any problems. Further enhancements like generics or enhanced For-Loops will be not supported. But since 2005 no activity was taking place around BeanShell and no updates were available yet. For further details look at BeanShell.


Groovy is a dynamic script language for the Java Virtual Machine and qualified for larger and professionally scripts because it generates Java classes. Groovy has some syntax variations to BeanShell, e.g. Initializing of arrays, limited support for inner classes,… (for details see also Differences between Groovy and Java or Differences from Java).

Comparison between BeanShell and Groovy

Due to the improved performance and especially due to continuous development of the Groovy scripting language is preferable to the BeanShell scripting language.
Generally, both languages ??have the following advantages and disadvantages:

Scripting languageAdvantagesDisadvantages
  • small library (~200 kB)
  • Complete Java syntax (to Java 1.4)
  • Is no longer being developed
  • Supports only syntax before Java 1.5 (So no generics, varargs, …)
  • Performance is significantly behind Compiled Groovy classes
  • No specialties, e.g. Closures or other code simplification
  • better performance
  • Is being actively developed
  • Many possibilities to develop code easier (e.g. by Closures)
  • big library (~5 MB)
  • slight deviations from the Java syntax (e.g. on array initializations)

To run jBEAM using scripting in Groovy, you have to download the Groovy library and add it into your jBEAM folder. For more details have a look at this description: Download and install the Groovy library.

How to write a script

In this chapter you will find some explanations about scripting. The first sections explains the posibilities how to create and how to write scripts. After this introduction, you can read some things about the execution, debugging and deployment of scripts. To improve your practical skills, the section deployment includes also some examples, that shows you how to use scripts in jBEAM.

Create a script file

There are a lot of possibilities to create Script Files. The simplest method is to use a basic text editor, e.g. Windows Note Pad. However, this method is inadequate due to the fact that Windows Note Pad does not include testing and script-line-auto-completion functionalities. Hence, the error rate is comparatively high. You can also use a IDE to create your script files. There are a lot of, like Eclipse, or NetBeans, which you can choose. Possibly the script-line-auto-completion functionalities of these IDE´s are a little bit better, if your are using special plugins. But there are also no posibilities for direct testing. In contrast, jBEAM contains the Script Editor allowing quick and comfortable component creation since the editor tests and executes scripts directly.

Write script

If you want to write scripts successfully, it is essential to be familiar with the basic functions of computers and programming languages. If you have no programming knowledge, it might be harder than expected to write scripts.
Before you begin to write your script now, you first have to know, what you are allowed to write. That means you should know something about syntax of the scripting language and about the jBEAM API before. You can find the necessary knowledge about the different scripting languages above on this page or on the websites of these scripting languages. But for a useful handling of the scripts, you have to know something about the functionality that is given by the API you want to use. jBEAM includes a set of important components, which give you different kinds of access to the functionality of jBEAM. For more information about it, have a look at the JAVADOC of jBEAM, at the Structure of jBEAM and at the Components of jBEAM.
If you meet all necessary requirements, you can begin to write your scripts. There are different posibilities to write a script file, using jBEAM. One of them is to write your script code into a script file with the extension .groovy or .bsh. After that this script file can be direct executete by jBEAM. Another posibility is to write your script direct in jBEAM. jBEAM provides its own script-editor for this way. You can find this editor by running jBEAM and navigate in the menulist to Extra->Miscellaneous->Scripting.

Execute script

When you´ve written your script, you also want to run it. So you need to know, which posibilities exists to execute a script file. Here you will find more information about it:

Debug script

If you are writing scripts in a texteditor or in an IDE, you only get a result by executing the written script. But if there are some errors in the script, you also be able to realize them during the execution. So there was no posibility to be informed about erros or to debug them before. So what you need, is something to debug or test your script before execution to prevent such errors. In contrast to this jBEAM offers some functionality to debug and to test your scripts before execute them. You can read more about here:

Deploy script

It is often necessary to deploy your scripts on another computer. In this case you have to think about the structure of your scripts. If your scripts are big or difficult to understand, it is better to outsource the logic of many scripts into one script library, which offers the functionality. So you can keep your scripts small and easy, because they only call the functions of the script library, which includes the whole logic. You now only have to write a start script, which starts jBEAM and to overtake a script as parameter, which calls the functions of the script library.

Use cases / Examples

See also

External links


Copyright by Kistler Chemnitz GmbH 2021
XWiki Enterprise 4.4 - Documentation