Using a pluggable scripting engine (JSR 223)
- Adding a scripting engine
- Selecting a scripting engine
- Implementing a script
- Running a script
- 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
-
Select the menu item Scripting -> Configure …
-
Select the tab Script engines
-
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.
-
Display the scripting console, select the menu item Scripting -> Show Scripting Console
-
Click on Change to select a scripting engine
-
Select one of the configured scripting engines
Implementing a script
-
Display the scripting console, select the menu item Scripting -> Show Scripting Console
-
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
-
Display the scripting console, select the menu item Scripting -> Show Scripting Console
-
Enter the script or load it from a file (menu File -> Open)
-
Click on Run
From a script
-
Select the menu item Scripting -> Run …
-
Select the file
-
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.