Install GraalVM with Homebrew

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

1
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:

1
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:

1
2
3
4
5
6
/usr/libexec/java_home -V
```<figure class="wp-block-image size-large">

<img decoding="async" loading="lazy" width="800" height="106" src="https://blog.ataiva.com/wp-content/uploads/2021/11/image-1-800x106.png" alt="" class="wp-image-8283" srcset="https://blog.ataiva.com/wp-content/uploads/2021/11/image-1-800x106.png 800w, https://blog.ataiva.com/wp-content/uploads/2021/11/image-1-300x40.png 300w, https://blog.ataiva.com/wp-content/uploads/2021/11/image-1-768x101.png 768w, https://blog.ataiva.com/wp-content/uploads/2021/11/image-1.png 954w" sizes="(max-width: 800px) 100vw, 800px" /> </figure> 

This now needs to be added to the `PATH`, but first let&#8217;s make sure we can reference the new location:

/usr/libexec/java_home -v 1.17

1
2
3
4
5
6

..should print out the newly created entry&#8217;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

1
2
3
4

### Step4:

Now to complete the installation, simply run the following:

gu install native-image

1
2
3
4
5
6

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

### Step5:

`native-image` will now be added to the path.