Keywords: custom jmri script, jython, automation, combine java python, user scripts, jython examples

## JMRI: Scripting

since 4.23.3

Note: The PanelPro main menu is being changed. The four scripting related menu items have moved from the Panels menu item to the new Scripting menu item. The menu references in the scripting related documents show the new menu path with the old value in braces.

Writing and executing a "script" (program in Python/Jython or other language - see below) is a way of telling JMRI to execute commands specific to your JMRI environment and to partially or even fully automate your layout and train operations. Scripts can be as simple as telling JMRI to set a single sensor or as complex as setting up multiple objects and running multiple trains based on feedback from your layout. While there is no comprehensive JMRI scripting manual, the examples provided in the pages linked below will be a primary source of information on how to use scripting to great advantage with JMRI. The "How To" and "What-Where" sections also provide many ideas and hints gleaned from the JMRI community on scripting features and capabilities.

The following pages discuss scripting JMRI using the Jython version of Python:

- Getting started with simple scripts
- The Python/Jython language
- Example script: Setting the default state of turnouts
- Many other example scripts (Links)
- Lots of "How To..." for JMRI scripting
- "What...Where" interesting tidbits about creating Jython scripts for use with JMRI
- Modifying the GUI with Jynstruments
- Jython Apps: complete apps that use JMRI jython
- Open Scripting Architecture (available for Mac)

See also the help section on Python and JMRI.

Any Java Scripting API (commonly refered to JSR-223) compliant scripting language can be added to JMRI, however, only JavaScript and Python (Jython) are directly supported in the default installation. If you want to add another scripting language, find a JSR-223 compliant interpreter and add it to the JMRI classpath as documented for your operating system (different operating systems have different launchers that are configured differently).