How to Install GraalVM on Mac


Install GraalVM with Homebrew

Homebrew is the preferred way to install anything on your Mac.

brew install graalvm/tap/graalvm-ce-java17

Install GraalVM without Homebrew

Follow these 5 steps to get GraalVM installed on your Mac.

Step1:

Download the official binary: https://www.graalvm.org/downloads/

Unpack the archive into a folder.

Step2:

Move the folder into the JavaVirtualMachines directory:

sudo mv graalvm-ce-java17-21.3.0 /Library/Java/JavaVirtualMachines

sudo is required because /Library is a system directory.

Step3:

Verify the installation using the java_home utility:

/usr/libexec/java_home -V

This now needs to be added to the PATH, but first let’s make sure we can reference the new location:

/usr/libexec/java_home -v 1.17

..should print out the newly created entry’s absolute directory path as above:

/Library/Java/JavaVirtualMachines/graalvm-ce-java17-21.3.0/Contents/Home

Open you ~/.bash_profile and add:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.17)
export PATH=$JAVA_HOME/bin:$PATH

Step4:

Now to complete the installation, simply run the following:

gu install native-image

This binary is located at /Library/Java/JavaVirtualMachines/graalvm-ce-<version>/Contents/Home/bin if it’s not immediately available.

Step5:

native-image will now be added to the path.