GraalVM is a high-performance virtual machine built by Oracle that can run applications written in JavaScript, Python, Ruby, R, JVM-based languages such as Java, Scala, Kotlin, and LLVM-based languages. like C and C++. Using GraalVM, you do not need to install many different software to program in different languages, just install GraalVM is enough. In this tutorial, I will guide you all how to install GraalVM on macOS.
To install GraalVM, first go to https://www.graalvm.org/downloads/. GraalVM currently has two Community and Enterprise editions, and you can see the differences in the two versions on this download page. Here, I will be using the Community version, so I will go to the https://github.com/graalvm/graalvm-ce-builds/releases/ page to download the GraalVM installation file.
After downloading the GraalVM installation file, unzip this file:
To use GraalVM anywhere on your machine, you need to set the environment variable pointing to the bin directory of the GraalVM directory. But since I currently have a Java version installed on my machine, to avoid touching, I just export a GRAALVM_HOME variable that points to the GraalVM Home folder.
To export the GRAALVM_HOME variable as I said above, I would open the .bash_profile file inside the user directory and add the following line:
1 |
export GRAALVM_HOME=/Users/Khanh/Downloads/graalvm-ce-java11-21.1.0/Contents/Home |
Run the following command for our installation to take effect immediately:
1 |
. ~/.bash_profile |
If you are using macOS Catalina or later, you need to run the following command to remove the checking software of macOS:
1 |
sudo xattr -r -d com.apple.quarantine <path_to_graalvm_folder> |
My example is as follows:
1 |
sudo xattr -r -d com.apple.quarantine /Users/Khanh/Downloads/graalvm-ce-java11-21.1.0/ |
OK, now I can check the results.
To check out the Java version that GraalVM has, you can use the following command
1 |
$GRAALVM_HOME/bin/java -version |
Result:
By default, GraalVM only supports Java language, for other languages like NodeJS, Ruby, R, Python, … if you need to use it, let use the gu tool in the bin directory of the GraalVM installation directory to install them. For example, if I need to install NodeJS, I will run the following command:
1 |
$GRAALVM_HOME/bin/gu install nodejs |
Result:
Check NodeJS version:
1 |
$GRAALVM_HOME/bin/node --version |
and npm version:
1 |
$GRAALVM_HOME/bin/npm --version |
Result:
You can also install Ruby as follows:
1 |
$GRAALVM_HOME/bin/gu install ruby |
Result:
To build Native Images, you can also install the native-image component as follows:
1 |
$GRAALVM_HOME/bin/gu install native-image |
Result:
It is great, isn’t it? 🙂
Zhangjing
Now you can install by
brew cask install graalvm/tap/graalvm-ce
Taysay Shaguy
cool, many thanks
Yuri Mednikov
Hi, Khanh! Thanks for this post, it really helped me today!
Khanh Nguyen
Glad to hear that. 🙂
Gibson
thanx Khanh , simple installation instructions