728x90
반응형

 

CentOS8에서 자바 버전 1.11 에서 1.17로 변경

 

1. 현재 자바 버젼 확인

# java -version
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

 

2. 설치 가능한 java 버젼 확인

# yum list java*jdk-devel
Last metadata expiration check: 1:45:54 ago on Thu 29 Feb 2024 05:22:45 PM KST.
Installed Packages
java-11-openjdk-devel.x86_64                                                            1:11.0.13.0.8-4.el8_5                                                           @appstream
Available Packages
java-1.8.0-openjdk-devel.x86_64                                                         1:1.8.0.312.b07-2.el8_5                                                         appstream
java-17-openjdk-devel.x86_64                                                            1:17.0.1.0.12-2.el8_5                                                           appstream

 

3. 원하는 버젼 설치

# yum install -y java-17-openjdk-devel.x86_64
Last metadata expiration check: 1:47:33 ago on Thu 29 Feb 2024 05:22:45 PM KST.
Dependencies resolved.
==================================================================================================================================================================================
 Package                                            Architecture                     Version                                            Repository                           Size
==================================================================================================================================================================================
Installing:
 java-17-openjdk-devel                              x86_64                           1:17.0.1.0.12-2.el8_5                              appstream                           5.1 M
Installing dependencies:
 java-17-openjdk                                    x86_64                           1:17.0.1.0.12-2.el8_5                              appstream                           244 k
 java-17-openjdk-headless                           x86_64                           1:17.0.1.0.12-2.el8_5                              appstream                            41 M

Transaction Summary
==================================================================================================================================================================================
Install  3 Packages

..
..
..
Installed:
  java-17-openjdk-1:17.0.1.0.12-2.el8_5.x86_64          java-17-openjdk-devel-1:17.0.1.0.12-2.el8_5.x86_64          java-17-openjdk-headless-1:17.0.1.0.12-2.el8_5.x86_64

Complete!

 

4. Default Java 변경하기

# /usr/sbin/alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-4.el8_5.x86_64/bin/java)
   2           java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin/java)

Enter to keep the current selection[+], or type selection number: 2

 

5. 환경변수 재설정

# java -version
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

# echo $JAVA_HOME
/usr/bin/javac

# vi /etc/profile
--> 삭제 JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.i386
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

 

6. 자바 버젼 확인

# su - root
Last login: Thu Feb 29 19:44:10 KST 2024 on pts/0

# echo $JAVA_HOME
/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64

# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin:/root/bin

# java -version
openjdk version "17.0.1" 2021-10-19 LTS
OpenJDK Runtime Environment 21.9 (build 17.0.1+12-LTS)
OpenJDK 64-Bit Server VM 21.9 (build 17.0.1+12-LTS, mixed mode, sharing)
728x90
반응형
LIST

'programming > java' 카테고리의 다른 글

Tomcat 설치 및 Manager 설정(403 Access Denied)  (0) 2024.03.01

+ Recent posts