Graalvm安装

本文最后更新于:星期一, 九月 12日 2022, 1:25 凌晨

graalvm

下载

从下面链接 https://github.com/graalvm/graalvm-ce-builds/releases 下载

我的电脑 macOS (aarch64/M1)且已安装java17

java17

https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.1.0/graalvm-ce-java17-darwin-aarch64-22.1.0.tar.gz

If you are using macOS Catalina and later you may need to remove the quarantine attribute from the bits before you can use them
To do this, run the following:

sudo xattr -r -d com.apple.quarantine path/to/graalvm/folder/

安装

迁移到java安装目录,并设置JAVA_HOME

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

export PATH=/Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.1.0/Contents/Home/bin:$PATH

export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.1.0/Contents/Home

验证

To check whether the installation was successful, run the java -version command.

native-image

下载

java17

https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.1.0/native-image-installable-svm-java17-darwin-aarch64-22.1.0.jar

sudo mv native-image-installable-svm-java17-darwin-aarch64-22.1.0.jar /Library/Java/JavaVirtualMachines/
sudo gu install -L native-image*

制作快捷路径

vi /usr/local/bin/native-image

加入以下内容

oldJH=$JAVA_HOME
JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.1.0/Contents/Home
oldPath=$PATH
PATH=$JAVA_HOME/bin:$PATH
native-image $*
JAVA_HOME=$oldJH
PATH=$oldPATH

然后赋权

chmod +x /usr/local/bin/native-image

验证

随便哪个目录输入native-image --help ,出现下图所示即安装成功

安装成功


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!