Using a pluggable scripting engine (JSR 223)

  1. Adding a scripting engine
  2. Selecting a scripting engine
  3. Implementing a script
  4. Running a script
    1. In the scripting console
    2. From a script
  5. Sample Scripts

JSR 223 defines how scripting engines can be embedded on the Java platform.

The scripting plugin makes use of this standard. You can add any JSR223-compatible scripting engine and use it for scripting in JOSM.

Adding a scripting engine

  1. Select the menu item Scripting -> Configure …

  2. Select the tab Script engines

  3. Download one of the scripting engines for Python, Groovy, or Ruby. Or download another scripting language and add its jar file on this tab.

Selecting a scripting engine

In the scripting console you can select a scripting engine to run a script.

  1. Display the scripting console, select the menu item Scripting -> Show Scripting Console

  2. Click on Change to select a scripting engine

  3. Select one of the configured scripting engines

Implementing a script

  1. Display the scripting console, select the menu item Scripting -> Show Scripting Console

  2. Select a script engine

  3. Enter the script in the scripting console. The example in the following screen shot is a simple Python script. The scripting plugin executes it with the Jython scripting engine.

Running a script

In the scripting console

  1. Display the scripting console, select the menu item Scripting -> Show Scripting Console

  2. Enter the script or load it from a file (menu File -> Open)

  3. Click on Run

From a script

  1. Select the menu item Scripting -> Run …

  2. Select the file

  3. Click Run

If the scripting plugin can’t infer a suitable scripting engine, it displays a dialog where you can select one of the available scripting engines.

Sample Scripts

Sample scripts for JavaScript, Python, Groovy, and Ruby are available here.