Oracle GraalVM on an OCI Compute Instance with Oracle Linux

This guide describes how to install Oracle GraalVM on an Oracle Cloud Infrastructure (OCI) Compute instance with Oracle Linux 7, 8, and 9. For complete beginners, start with this tutorial to create and launch your first Linux instance.

Note: Oracle GraalVM license and support are included in the Oracle Cloud Infrastructure subscription at no additional cost.

Prerequisites

To replicate the steps in this guide, create a Compute instance and connect to it.

Install Oracle GraalVM

For convenience, Oracle GraalVM RPMs are available in the Oracle YUM repository. RPMs for Oracle GraalVM for JDK 17, JDK 21, and JDK 23 are available with the package names graalvm-17-native-image, graalvm-21-native-image, and graalvm-23-native-image, respectively. These Oracle GraalVM distributions include a JDK and the Native Image tool. Each Oracle GraalVM RPM is self-contained and all required dependencies will be automatically resolved during installation.

That means that OCI customers can use Oracle GraalVM in their compute instances, just like any other Java Development Kit, by installing it with yum, dnf, or microdnf default package managers, depending on the Oracle Linux version.

Use the following command to connect to the OCI Compute Instance from a Unix-style system:

ssh -i .ssh/id_rsa opc@INSTANCE_PUBLIC_IP

Where .ssh/id_rsa is the full path and name of the file containing your private SSH key; opc is the default name for the Oracle Linux image; and INSTANCE_PUBLIC_IP is the instance IP address provisioned from the console. For more details, refer to theĀ Connecting to Your Linux Instance Using SSH tutorial.

The installation steps may differ per Oracle Linux version or package manager.

Oracle Linux 7

  1. Install a newer devtoolset with GCC version 10 (required by Oracle GraalVM Native Image):
    sudo yum -y install oracle-softwarecollection-release-el7
    
    sudo yum install devtoolset-10
    
  2. Enable the newer devtoolset by default:
    echo 'source scl_source enable devtoolset-10' >> ~/.bashrc
    
  3. Enter a new bash session with the newer devtoolset enabled:
    bash
    
  4. Install the latest Oracle GraalVM:
    sudo yum install graalvm-23-native-image
    

    Confirm that the installed package size is correct by entering yes at the prompt.

Oracle Linux 8

On Oracle Linux 8 with the yum package manager, run these commands one by one:

sudo yum update -y oraclelinux-release-el8
sudo yum config-manager --set-enabled ol8_codeready_builder
sudo yum install graalvm-23-native-image

Confirm that the installed package size is correct by entering yes at the prompt.

On Oracle Linux 8 with dnf or microdnf default package managers, run these commands one by one:

sudo dnf update -y oraclelinux-release-el8
sudo dnf config-manager --set-enabled ol8_codeready_builder
sudo dnf install graalvm-23-native-image

Oracle Linux 9

On Oracle Linux 9 with the yum package manager, run these commands one by one:

sudo yum update -y oraclelinux-release-el9
sudo yum config-manager --set-enabled ol9_codeready_builder
sudo yum install graalvm-23-native-image

Confirm that the installed package size is correct by entering yes at the prompt.

On Oracle Linux 9 with dnf or microdnf default package managers, run these commands one by one:

sudo dnf update -y oraclelinux-release-el9
sudo dnf config-manager --set-enabled ol9_codeready_builder
sudo dnf install graalvm-23-native-image

Configure Environment Variables

Configure environment variables to point to the Oracle GraalVM installation for this SSH session. After installation, the package files are placed in the /usr/lib64/graalvm directory, and binaries in bin accordingly.

  1. Set the values of the PATH and JAVA_HOME environment variables in the bash configuration to point to the location of the Oracle GraalVM installation with the following commands:
    echo "export JAVA_HOME=/usr/lib64/graalvm/graalvm-java23" >> ~/.bashrc
    
    echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
    
  2. Activate this change:
    source ~/.bashrc
    
  3. Check the values of PATH and JAVA_HOME, and the Java version to confirm the installation was successful:
    echo $JAVA_HOME
    
    echo $PATH
    
    java -version
    

Congratulations! You have installed Oracle GraalVM on the Compute instance with the Oracle Linux image, and can use it as any other Java Development Kit.