Skip to content

Setting Up GraalVM

Somnath Musib edited this page Dec 6, 2021 · 6 revisions

In this section, we'll discuss how to set up GraalVM.

Windows

  1. Download GraalVM installer from https://www.graalvm.org/downloads/
  2. For this demonstration, we'll use Java 11 based installer
  3. Once downloaded, extract the components
  4. Browse to Environment variables and set the root folder as the JAVA_HOME environment variable as the user variable
  5. Edit the path environment variable and include %JAVA_HOME%/bin
  6. Open a command prompt window and validate the Java version with the java --version command: e.g.
> java --version
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05, mixed mode, sharing)

The java is now pointed to GraalVM.

  1. Install native-image using the GraalVM Updated tool with the following command
> gu install native-image
Downloading: Release index file from oca.opensource.oracle.com
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Downloading: Component native-image: Native Image  from github.com
Installing new component: Native Image (org.graalvm.native-image, version 21.3.0)
  1. Post installation, access the native-image version with the following command:
> native-image --version
GraalVM 21.3.0 Java 11 CE (Java Version 11.0.13+7-jvmci-21.3-b05)

Linux

  1. Download GraalVM installer from https://www.graalvm.org/downloads/
  2. For this demonstration, we'll use Java 11 based installer
  3. Once downloaded, extract the tar.gz file and set the root folder as the JAVA_HOME environment variable. Also set the $JAVA_HOME\bin e.g.
> export JAVA_HOME=/home/musibs/graalvm-ce-java11-21.3.0
> export PATH=$PATH:$JAVA_HOME/bin
  1. Open a terminal window and validate the Java version with the java --version command: e.g.
> java --version
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05, mixed mode, sharing)
  1. Install native-image
> gu install native-image
Downloading: Release index file from oca.opensource.oracle.com
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Downloading: Component native-image: Native Image  from github.com
Installing new component: Native Image (org.graalvm.native-image, version 21.3.0)
  1. Check native-image version:
> native-image --version
GraalVM 21.3.0 Java 11 CE (Java Version 11.0.13+7-jvmci-21.3-b05)