Oracle GraalVM in OCI Cloud Shell

This guide shows you how to get started with Oracle GraalVM in Oracle Cloud Infrastructure (OCI) Cloud Shell.

OCI Cloud Shell is a browser-based terminal accessible from the Oracle Cloud Console. It provides access to a Linux shell with a pre-authenticated OCI Command Line Interface (CLI), preinstalled developer tools, and comes with 5GB of storage.

Oracle GraalVM JDK 17 with Native Image is preinstalled in Cloud Shell, so you do not have to install and configure a development machine.

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

Steps to Use Oracle GraalVM in Cloud Shell

Cloud Shell has several preinstalled JDKs, including Oracle GraalVM JDK.

  1. Login to the Oracle Cloud Console and launch Cloud Shell.

  2. List the installed JDKs using the csruntimectl java list command.

     csruntimectl java list

    The output lists the JDKs preinstalled in Cloud Shell: GraalVM for JDK 17, Oracle JDK 11, and Oracle JDK 8. The JDK marked with an asterisk is the current JDK.

  3. Select GraalVM for JDK 17 as the current JDK:

     csruntimectl java set graalvmeejdk-17

    You will see the confirmation message printed The current managed java version is set to graalvmeejdk-17.

  4. Now confirm the values of the environment variables PATH and JAVA_HOME, and the version of java, the native-image generator:

     echo $JAVA_HOME
     echo $PATH
     java -version
     native-image --version

You are all set to run Java applications using Oracle GraalVM JDK in Cloud Shell.

Run a Java Application

The example that you will run is a minimal REST-based application, built on top of Spring Boot using Maven. The pom.xml file was generated using Spring Initializr with Spring Native Tools added as a feature. The Spring AOT plugin performs ahead-of-time transformations of a Spring application into a native executable.

  1. Clone the demos repository and change to the application root directory:

    git clone
    cd graalvm-demos/spring-native-image
  2. Build the application with Maven (Apache Maven is also preinstalled in Cloud Shell):

     mvn clean package

    This will generate a runnable JAR file that contains all of the application’s dependencies as well as a correctly configured MANIFEST file.

  3. Run the Java application:

     java -jar ./target/benchmark-jibber-0.0.1-SNAPSHOT.jar &

    Call the REST endpoint:

     curl http://localhost:8080/jibber

    You should see some nonsense verse printed.

    Bring the application to the foreground:


    Terminate the application by pressing Ctrl+c.

  4. Next, build a native executable for this Spring Boot application using the native Maven profile.

     mvn -Pnative native:compile

    This will generate a native executable for Linux in the target directory, named benchmark-jibber.

  5. Run the native executable, using the following command:

    ./target/benchmark-jibber &

    Call the endpoint to test:

     curl http://localhost:8080/jibber

    Again, you should see some nonsense verse printed.

    Bring the application to the foreground:


    Terminate the application by pressing Ctrl+c.

Congratulations! You have successfully used Oracle GraalVM JDK with Native Image to build and test a Spring Boot REST application in Cloud Shell.

Thus, you can easily use Oracle GraalVM in OCI Cloud Shell to build and test simple Java applications with Micronaut, Spring, and other microservice frameworks.