Scripting with BeanShell

From OpenJUMP Wiki
Jump to navigation Jump to search

What is BeanShell?

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript.

In the context of Jump, BeanShell enables the automation of repetative tasks or to accomplish tasks that are not possible using the GUI without the need for plugin modules or modification of the application source code.

See for more information on BeanShell.

BeanShell in OpenJUMP

To open the BeanShell scripting window select the following menu option:

View -> BeanShell...

It is a good idea to surround all your scripts in a set of braces. I.e.


In BeanShell you may access JavaBean properties as if they were fields. For example wc.layerManager is the same as wc.getLayerManager().

There is no facility to save and load a script. If you plan to reuse your scripts, develop the script in a text editor and then paste into the BeanShell window as needed.

If you want to write Beanshell scripts you can also use the Beanshell-Editor-JUMP Plugin (bsheditor4jump-0.2.jar) that has been written by Michael Michaud.

JUMP BeanShell examples

Some of the following scripts are not very useful. Instead they are indented as examples which can be easily adapted to perform useful tasks.