Installing Graal Script Engine

Summary

GraalVM is a full virtual machine in its own right, a component of which is the Graal Script Engine, which can be dropped into existing Java Virtual Machine installations to enable it to be used in place of Nashorn.

Install into JDK - Recommended method

Java 8

  1. Download from Download GraalVM (eg the GraalVM Community 20.1.0 version), the archive that is appropriate for your OS, eg (Java8) graalvm-ce-java8-linux-amd64-20.1.0.tar.gz

  2. Unzip the archive and enter the folder created and copy the following files:

    1. ./jre/languages/js/graaljs.jar ./jre/languages/js/icu4j.jar ./jre/lib/truffle/truffle-api.jar ./jre/lib/boot/graal-sdk.jar ./jre/lib/boot/graaljs-scriptengine.jar
  3. Paste these files into $JAVA_HOME/jre/lib/ext

  4. $JAVA_HOME/jre/lib/ext should look like the following:

    1. image-20200812-102226.png

Now once you restart Jira you then be able to use Graal as the scripting language for the script features.

 

Java 11 / Java 17

  1. Download the Relevant Graalvm files, can be downloaded by using the following:

    1. wget https://repo1.maven.org/maven2/org/graalvm/sdk/graal-sdk/22.3.0/graal-sdk-22.3.0.jar wget https://repo1.maven.org/maven2/com/ibm/icu/icu4j/71.1/icu4j-71.1.jar wget https://repo1.maven.org/maven2/org/graalvm/js/js/22.3.0/js-22.3.0.jar wget https://repo1.maven.org/maven2/org/graalvm/truffle/truffle-api/22.3.0/truffle-api-22.3.0.jar wget https://repo1.maven.org/maven2/org/graalvm/js/js-scriptengine/22.3.0/js-scriptengine-22.3.0.jar wget https://repo1.maven.org/maven2/org/graalvm/regex/regex/22.3.0/regex-22.3.0.jar
  2. Add module-info.class to icu4j-71.1.jar as this is not included by standard and is required. See the Adding module-info.class within the Jar file heading below for more info.

  3. Place these files into $JAVA_HOME/jmods

Adding module-info.class within the Jar file

When jar files are made they sometimes do not contain a Module-info.class file which is used to identify that the jar file can be used as a Java module. You are able to create the module-info.class file by using the following commands and this will then mean that the jar file can be used as a module within the Java Runtime Environment.

  1. Creating module-info.java

The following terminal command will generate a module-info.java file that contains the relevant information about the jar file.

jdeps --generate-module-info out icu4j-71.1.jar
  1. Compile module-info.java to create module-info.class

This will compile the module-info.java file into a module-info.class which can then be used to identify the jar file as a module.

  1. Add the missing module-info.class into the jar file.

Move module-info.class from out/com.ibm.icu/module-info.class to the same folder as icu4j-71.1.jar and then run the following to place the created module-info.class file into the jar file.

  1. Create the new runtime folder with graal module support

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

Update $JAVA_HOME to point to the new JRE folder.

Install into Jira-install/lib

Java 8

  1. Download the Relevant Graalvm files, can be downloaded by using the following:

  2. Copy these downloaded files into <jira_install_directory>/lib folder

  3. Restart Jira

Once restart you should see that Graal.js is listed as a Script Engine within JEMH > Extensions > Detected Script Engines

Java 11 / Java 17

  1. Download the Relevant Graalvm files, can be downloaded by using the following:

  2. Copy these downloaded files into <jira_install_directory>/lib folder

  3. Restart Jira

Once restart you should see that Graal.js is listed as a Script Engine within JEMH > Extensions > Detected Script Engines

Screenshot from 2024-01-03 14-40-18.png