Install GraalVM on windows 10 / Linux / Mac OS

0
2398

This is a GraalVM community edition installation guide on Windows 10, Linux and Mac systems. Getting GraalVM installed and ready-to-go should only take a few minutes. Choose a platform and proceed to the installation steps :

GraalVM is a Java Virtual Machine (JVM) and Java Development Kit (JDK) created by Oracle. It supports additional programming languages such as Java, Scala, and Kotlin, but also to other programming languages such as JavaScript, Ruby, Python, and R. Additionally, it enables the execution of native code via an LLVM front-end, and WebAssembly programs on the JVM.

1. Installation

Follow these steps to install GraalVM Community Edition on x86 64-bit Windows. 

1. There are distributions available based on OpenJDK 8 and OpenJDK 11, you can choose any one of them. Download GraalVM CE form GraalVM Releases repository on GitHub . We will focus on GRaalVM CE based on OpenJDK 11 which is graalvm-ce-java11-windows-amd64-20.1.0.zip.

2. Unzip the archive to your file system.

3. Configure GRAALVM_HOME and PATH environment variables.

3.1. Manual Configuration : Right Click on “My Computer” –> Select “Properties” option –> Select “Advanced system setting” option –> click on “Environment variables..” button –> click on “New..” under system variable –> then set the “GRAALVM_HOME” and your downloaded archive extracted location like following image.

Similarly Add “JAVA_HOME” system variable. JAVA_HOME also set to “Z:\D\graalvm\graalvm-ce-java11-20.1.0”.

GRAALVM_HOME variable on windows 10

To set Path environment variable for GraalVM select “Path” under System variables and click on “Edit..” button. A new window opens –> click on “New” –> set GraalVM bin directory path ( Ex: “Z:\D\graalvm\graalvm-ce-java11-20.1.0\bin”) in the field –>click “Ok” button.

GraalVM path environment variable on windows

3.2. Using Command Line : Start windows command prompt as administrator and issue the following commands.

Set GRAALVM_HOME :

setx /M GRAALVM_HOME "Z:\D\graalvm\graalvm-ce-java11-20.1.0"

Set JAVA_HOME : To run your java programs on GraalVM

$ setx /M JAVA_HOME "Z:\D\graalvm\graalvm-ce-java11-20.1.0"

Set Path System Variable :

$ setx /M PATH "Z:\D\graalvm\graalvm-ce-java11-20.1.0;%PATH%"

4. Test the Setup :

To test your setup working properly, restart your command prompt and issue command java -version you will get following results.

$ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)

5. Your GraalVM setup is done.

Follow these steps to install GraalVM Community Edition on x86 64-bit Linux operating systems. (This setup was done on Linux Ubuntu)

1. Download GraalVM CE form GraalVM Releases repository on GitHub . We will focus on GRaalVM CE based on OpenJDK 11 which is graalvm-ce-java11-linux-amd64-20.1.0.zip.

2. If you wants to download from command line, you can use following command.

$ wget -P "Path Where to download" "download URL"

Example :

$ wget -P /home/ubuntuadmin/Documents/ "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.1.0/graalvm-ce-java11-linux-amd64-20.1.0.tar.gz"

3. Extract the downloaded archive file. Navigate command to location Ex: $cd /home/ubuntuadmin/Documents/ and run following command.

$ tar xz -f graalvm-ce-java11-linux-amd64-20.1.0.tar.gz

4. Run Following commands to set Java and GraalVM environment variables.

$ sudo gedit ~/.bashrc     OR  sudo nano ~/.bashrc 

File will open, add the following paths, make sure adjust the according to your actual paths.

GRAALVM_HOME="/home/ubuntuadmin/Documents/graalvm-ce-java11-20.1.0"
JAVA_HOME="$GRAALVM_HOME"
PATH="$JAVA_HOME/bin":"$GRAALVM_HOME/bin":$PATH

Save the file and run following command to refresh configuration settings.

$ source ~/.bashrc 

5. Configuration done. To test the configuration run following command.

$ java -version

Upon successful configuration you will get output like following.

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)

Follow these steps to install GraalVM Community on x86 64-bit macOS operating systems.

1. Download GraalVM CE form GraalVM Releases repository on GitHub . We will focus on GRaalVM CE based on OpenJDK 11 which is graalvm-ce-java11-darwin-amd64-20.1.0.zip.

2. Extract the archive to your file system. To extract it in the Downloads directory from the console, type:

$ tar -xvf ~/Downloads/graalvm-ce-java11-darwin-amd64-20.1.0.tar.gz -C ~/Downloads/

3. Move the obtained GraalVM to its proper location, the /Library/Java/JavaVirtualMachines directory. Since this is a system directory, sudo is required:

$ sudo mv ~/Downloads/graalvm-ce-java11-20.1.0 /Library/Java/JavaVirtualMachines

4. Open .bash_profile to set System environment variables.

$ sudo open -a TextEdit .bash_profile      OR    sudo nano .bash_profile

5. Add the following lines and save .bash_profile file.

export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home
export JAVA_HOME=$GRAALVM_HOME
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

6. Refresh the settings from .bash_profile.

$ source .bash_profile

7. GraalVM setup is done on Mac OS, to test the setup run java -version command.

$ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)

2. Installing Additional Components

To add support for Python, R, Ruby or WebAssembly languages interpreters in GraalVM Community Edition, use a functional gu utility. To know the available additional components for your machine run $ gu available utility command. Following are the available components on Mac OS can be download and to be installed.

$ gu available
Downloading: Component catalog from www.graalvm.org
ComponentId              Version             Component name      Origin 
--------------------------------------------------------------------------------
llvm-toolchain           20.1.0              LLVM.org toolchain  github.com
native-image             20.1.0              Native Image        github.com
python                   20.1.0              Graal.Python        github.com
R                        20.1.0              FastR               github.com
ruby                     20.1.0              TruffleRuby         github.com
wasm                     20.1.0              GraalWasm           github.com

Installing native Image :

$ gu install native-image
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 20.1.0)

3. Conclusion

In this guide, we have covered how to setup GraalVM on Windows 10 OS, on Linux Ubuntu OS and Mac OS.

LEAVE A REPLY

Please enter your comment!
Please enter your name here