-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_graalvm.sh
executable file
·72 lines (51 loc) · 1.75 KB
/
install_graalvm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# based on https://github.com/DevInsideYou/install-graalvm
# remove yourself
#rm $0
if [ "$1" == "" ]; then
JAVA_VERSION="11"
else
JAVA_VERSION="$1"
fi
if [ "$2" == "" ]; then
GRAAL_VM_VERSION="20.3.0"
else
GRAAL_VM_VERSION="$2"
fi
# install curl
sudo apt install -yqqq curl
URL="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VM_VERSION}/graalvm-ce-java${JAVA_VERSION}-linux-amd64-${GRAAL_VM_VERSION}.tar.gz"
TARGET="graalvm-ce-java${JAVA_VERSION}-${GRAAL_VM_VERSION}"
ARCHIVE="${TARGET}.tar.gz"
JVM_LIB_DIRECTORY="/usr/lib/jvm"
# chande directory to /usr/lib/jvm
cd ${JVM_LIB_DIRECTORY}
# download the archive
sudo curl -L $URL -o $ARCHIVE
# unpack the archive
sudo tar -zxvf ${ARCHIVE}
# remove the archive
sudo rm ${ARCHIVE}
LINK="graalvm"
# symlink it for simplicity
# we assume here that ${TARGET} directory exists after the extraction
sudo ln -sfn ${TARGET} ${LINK}
GRAALVM_DIRECTORY="${JVM_LIB_DIRECTORY}/${LINK}"
# install graalvm as a java alternative
# 1081 is the same priority as the one used by the JVM from the OpenJDK
sudo update-alternatives --install /usr/bin/java java "${GRAALVM_DIRECTORY}/bin/java" 1081
SELECTION_SCREEN_CMD="sudo update-alternatives --config java"
echo
echo "Run '${SELECTION_SCREEN_CMD}' without the single quotes to get back to this selection screen any time."
echo
${SELECTION_SCREEN_CMD}
echo
echo "Run '${SELECTION_SCREEN_CMD}' without the single quotes to get back to this selection screen any time."
echo
echo "Run '${GRAALVM_DIRECTORY}/bin/gu install native-image' without the single quotes to install the native-image utility."
echo
java -version
echo
ls -l ${JVM_LIB_DIRECTORY} | grep graalvm
echo
echo "You might want to remove older versions from ${JVM_LIB_DIRECTORY}"