Installing Nashorn (ECMAScript) Script Engine

Summary

Within Java 8 and Java 11 Nashorn (ECMAScript) is included by default which means that you do not need to install Nashorn into Java/Jira in order to use the JEMH Scripting features.

If you are using Java 17+ then you will see that Nashorn (ECMAScript) is not included by default. Due to this it means that you would need to download and install the relevant Nashorn files to use the JEMH Scripting features. See below for two methods of how to install Nashorn.

Install Into JDK17 - Recommend Method

This method is recommended as it provides a more seamless support for your existing scripts where Jira components are used through Java.type(“nnnn”).

  1. Download the Relevant Nashorn files, can be downloaded by using the following (see https://repo1.maven.org/maven2/org/openjdk/nashorn/nashorn-core/ for the latest version):

wget https://repo1.maven.org/maven2/org/openjdk/nashorn/nashorn-core/15.4/nashorn-core-15.4.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm/9.6/asm-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.6/asm-commons-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.6/asm-tree-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-util/9.6/asm-util-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/9.6/asm-analysis-9.6.jar
  1. Place these downloaded files into $JAVA_HOME/jmods

  2. Run the following script to create a new Java Runtime Environment with all of the Java Modules (including the newly added modules):

    1. jlink --module-path $JAVA_HOME/jmods/ --add-modules ALL-MODULE-PATH --output jre
  3. Update $JAVA_HOME to point to the new JRE folder.

You should then see that ECMAScript (Nashorn) is listed as a Detected Script Engine within JEMH > Extensions > Detected Script Engines

Screenshot from 2024-01-03 11-26-46.png

Install directly into JIRA_INSTALL_DIR/lib not recommended

Known Issues

If you are using Java 17 (and its related compatible JEMH version JEMH 4.1.2+) this method works in terms of simple javascript evaluation but has problems where Jira components are used (eg Java.type(“nnnn”)) that break. If you encounter problems, log a support ticket and supply your script, highlighting this case:Getting support . We can work with you to solve this, some script are likely required.

the above method (Install Into JDK) does work correctly.

 

With this method of installing the additional scripting languages you will need to provide the relevant scripting jars into the Lib folder every-time you conduct a Jira upgrade. Using the method above (Install into JDK) means that you will only need to install these languages once. (As long as you are using the same Java version for the new instance)

  1. Download the Relevant Nashorn files, can be downloaded by using the following (see https://repo1.maven.org/maven2/org/openjdk/nashorn/nashorn-core/ for the latest version):

wget https://repo1.maven.org/maven2/org/openjdk/nashorn/nashorn-core/15.4/nashorn-core-15.4.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm/9.6/asm-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.6/asm-commons-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.6/asm-tree-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-util/9.6/asm-util-9.6.jar wget https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/9.6/asm-analysis-9.6.jar
  1. Copy these downloaded files into your <jira_install_directory>/lib folder

  2. Restart Jira

You should see that ECMAScript (Nashorn) is listed as a detected Language within JEMH > Extensions > Detected Script Engines

Screenshot from 2024-01-03 11-26-46.png