Temurin JDK 8과 11을 모두 설치하고 싶었는데 다음 단계에 따라 설치했습니다.
wget https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u312-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz
tar xzf OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz
sudo mv jdk8u312-b07/ /usr/lib/jvm/temurinjdk-8-hotspot-amd64
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/temurinjdk-8-hotspot-amd64/bin/java" 1081
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/temurinjdk-8-hotspot-amd64/bin/javac" 1081
하지만 이것이 100% 맞는지 확실하지 않으며 .jinfo 파일을 생성하려면 어떻게 해야 합니까?
답변1
당신은 사용할 수 있습니다Adoptium Debian / Ubuntu 저장소
Eclipse Adoptium GPG 키 추가
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add -
Eclipse Adoptium apt 저장소 추가
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
필요한 Temurin 버전을 설치하십시오.
sudo apt update # update if you haven't already sudo apt install temurin-8-jdk sudo apt install temurin-17-jdk
기본 버전 구성
sudo update-alternatives --config java
답변2
원래 AdoptOpenJDK deb 패키지에서 스크립트를 추출하고 다음과 같이 수정된 버전을 사용했습니다.
wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz
mkdir -p /usr/lib/jvm
sudo tar -xvvf OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz -C /usr/lib/jvm/
sudo ./java-alternative install /usr/lib/jvm/jdk-17.0.1+12
sudo ./java-alternative set /usr/lib/jvm/jdk-17.0.1+12
…
sudo ./java-alternative remove /usr/lib/jvm/jdk-17.0.1+12
스크립트 소스 코드:
#!/bin/sh
set -eu
priority=2222
#jdk_base_dir=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64
#jdk_base_dir=/usr/lib/jvm/jdk-17.0.1+12
jdk_base_dir="$2"
if [ ! -d "$jdk_base_dir" ]
then
echo "Invalid java directory. Choose one of: ";
ls -1d /usr/lib/jvm/*
exit
fi
tools="jaotc jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jfr jhsdb jimage jinfo jjs jlink jmap jmod jps jrunscript jshell jstack jstat jstatd keytool pack200 rmic rmid rmiregistry serialver unpack200 jexec jspawnhelper"
case "$1" in
install)
for tool in $tools ; do
for tool_path in "$jdk_base_dir/bin/$tool" "$jdk_base_dir/lib/$tool" ; do
if [ ! -e "$tool_path" ]; then
continue
fi
slave=""
tool_man_path="$jdk_base_dir/man/man1/$tool.1"
if [ -e "$tool_man_path" ]; then
slave="--slave /usr/share/man/man1/$tool.1 $tool.1 $tool_man_path"
fi
update-alternatives \
--install \
"/usr/bin/$tool" \
"$tool" \
"$tool_path" \
"$priority" \
$slave
done
done
;;
remove)
for tool in $tools ; do
for tool_path in "$jdk_base_dir/bin/$tool" "$jdk_base_dir/lib/$tool" ; do
if [ ! -e "$tool_path" ]; then
continue
fi
update-alternatives \
--remove \
"$tool" \
"$tool_path"
done
done
;;
set)
for tool in $tools ; do
for tool_path in "$jdk_base_dir/bin/$tool" "$jdk_base_dir/lib/$tool" ; do
if [ ! -e "$tool_path" ]; then
continue
fi
update-alternatives \
--set \
"$tool" \
"$tool_path"
done
done
;;
esac