Debian 11.2にOpenJDK 17 をインストールする

1.OS情報の確認

# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

2.OpenJDK 17 をインストールします

# apt -y install openjdk-17-jdk
略
Setting up openjdk-17-jdk:amd64 (17.0.1+12-1+deb11u2) ...
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode
Processing triggers for libgdk-pixbuf-2.0-0:amd64 (2.42.2+dfsg-1) ...

3.環境パスを設定します

# vi /etc/profile.d/java.sh
下記の内容を追記します
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which java)))))
export PATH=$PATH:$JAVA_HOME/bin

環境設定を反映します
# source /etc/profile.d/java.sh

4.javaバージョンを確認します

# java --version
openjdk 17.0.1 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-Debian-1deb11u2)
OpenJDK 64-Bit Server VM (build 17.0.1+12-Debian-1deb11u2, mixed mode, sharing)

 

Debian 11

Posted by arkgame