Installation
To build native Java apps, GraalVM needs to be installed on the local machine, or runs in containers.
There are several GraalVM distributions to use, see the table below:
Distribution | Description | License |
---|---|---|
Oracle GraalVM | New product name after Oracle contributing GraalVM to OpenJDK | Free to use in production and free to redistribute, at no cost, under the GraalVM Free Terms and Conditions. |
GraalVM Community Edition (CE) | Community edition on GitHub | Version 2 of the GNU General Public License with the “Classpath” Exception |
Oracle GraalVM Enterprise Edition (EE) | Subscription required for production | Oracle Technology Network License Agreement for GraalVM Enterprise Edition for developing, testing, prototyping, and demonstrating |
Liberica Native Image Kit | Based on GraalVM CE | EULA |
Mandrel | Quarkus specific distribution of GraalVM CE | Same as GraalVM Community Edition |
This website uses GraalVM Community Edition as the base version.
Local Installation
There are different versions of GraalVM CE based on the OpenJDK versions.
- Java 21 based (LTS)
- Java 17 based (LTS)
- Java 20 based (Latest non-LTS)
GraalVM Community Edition 21.0.1
is used in this website.
GraalVM Versioning
After GraalVM 22.3.3
release, GraalVM switched to a different versioning schema which aligns with OpenJDK versions. There are no specific GraalVM versions, only OpenJDK versions. For each OpenJDK version, there will be a matching GraalVM version. Old GraalVM releases can still be downloaded.
GraalVM itself still has a version to track changes. This version should be used for GraalVM SDK dependencies.
Install
Linux / macOS
with SDKMAN!
Oracle GraalVM and GraalVM CE can be installed with SDKMAN!.
- Oracle GraalVM
- GraalVM CE
sdk install java 21.0.1-graal
sdk install java 21.0.1-graalce
Manual
Depends on the GraalVM version,
- Download Oracle GraalVM releases from GraalVM.org and extract files to a proper location.
- Download GraalVM CE releases from GitHub and extract files to a proper location.
Windows
Depends on the GraalVM version,
- Download Oracle GraalVM releases from GraalVM.org and extract files to a proper location.
- Download GraalVM CE Windows releases from GitHub and extract files to a proper location.
Another option is to install WSL first, then install Ubuntu. This can make installation of GraalVM much easier.
Configure GraalVM
Set the GRAALVM_HOME
environment variable to the location of extracted GraalVM release.
export GRAALVM_HOME=<graalvm_directory>
Add GraalVM bin
directory to the PATH
environment variable.
export PATH=${GRAALVM_HOME}/bin:$PATH
If you want to use GraalVM as the default JDK, the JAVA_HOME
environment variable can be set to GraalVM's directory.
Install Native Image
GraalVM 21 already has Native Image feature bundled.
For old versions, Native Image feature needs to be installed with GraalVM Updater using
gu install native-image
.
The native-image
executable can be found in the ${GRAALVM_HOME}/bin
directory.
native-image
requires the local toolchain to run.
- macOS
- Ubuntu
- CentOS
- Windows
xcode-select --install
sudo apt-get install build-essential libz-dev zlib1g-dev
sudo yum install gcc glibc-devel zlib-devel
Install the Visual Studio Build Tools with the Windows 10 SDK. Open the x64 Native Tools Command Prompt and run native-image
.
To verify the installation of native-image
, run the command below to check the version.
native-image --version
Output likes below should be printed:
native-image 21.0.1 2023-10-17
GraalVM Runtime Environment Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19)
Substrate VM Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12, serial gc, compressed references)
Run in Containers
GraalVM container images are published to GitHub Container Registry. There are different packages and tags to choose for different GraalVM versions. GraalVM CE packages have the -community
suffix.
To use Native Image, packages native-image
or native-image-community
should be used.
The command below pulls container image of Oracle GraalVM CE 21.0.1
.
docker pull ghcr.io/graalvm/native-image-community:21.0.1
A container can be started using the pulled image.
docker run -it --rm ghcr.io/graalvm/native-image-community:21.0.1 bash