Mac
下载最新版 https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.3.0
把 graalvm 和 native-image都下载下来。
然后安装!
$ cd /opt/local/graalvm
$ tar -xzf *.tar.gz
$ export JAVA_HOME=/opt/local/graalvm/graalvm-ce-java17-21.3.0/Contents/Home
$ export oldPATH=$PATH
$ export PATH=$JAVA_HOME/bin:$PATH
$ gu install -L native-image*
$ javac HelloWorld.java
$ native-image HelloWorld
$ export PATH=$oldPATH
$ ./helloworld
Hello World!
做一个快捷方式:
vi /usr/local/bin/native-image
oldJH=$JAVA_HOME
JAVA_HOME=/opt/local/graalvm/graalvm-ce-java17-21.3.0/Contents/Home
oldPath=$PATH
PATH=$JAVA_HOME/bin:$PATH
native-image $*
JAVA_HOME=$oldJH
PATH=$oldPATH
chmod +x /usr/local/bin/native-image
Now you can play it like: native-image HelloWorld!
Enjoy your game! cheers!
网友评论