$ sudo apt update
$ sudo apt install openjdk-17-jdk
아님 그냥 switch user root
$ java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
/usr/lib/jvm/java-[버전]-openjdk-amd64/bin/java
$ sudo nano /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
$ source /etc/environment
$ echo $JAVA_HOME
/usr/lib/jvm/java-17-openjdk-amd64
· 설치한 java를 삭제하고 싶으면 "apt remove" 명령어를 사용한다.
$ sudo apt remove openjdk-17-jdk