Cloud Infra Architecture (AWS)/AWS Build

[AWS Linux] Java 설치 후 환경변수 설정하기

seongduck 2024. 7. 15. 17:27

1) Linux 설치

 

Java Platform, Standard Edition 11 Reference Implementations

Java Platform, Standard Edition 11 Reference Implementations The official Reference Implementation for Java SE 11 (JSR 384) is based solely upon open-source code available from the JDK 11 Project in the OpenJDK Community. This Reference Implementation a

jdk.java.net

wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz

 

2) 압축 해제

tar -xvzf openjdk-11+28_linux-x64_bin.tar.gz

 

3) 환경변수 설정

sudo mv jdk-11 /usr/local/ #관리 용이성

sudo vi /etc/profile.d/jdk11.sh #새로 생성
"""
export JAVA_HOME=/usr/local/jdk-11
export PATH=$JAVA_HOME/bin:$PATH
"""

source /etc/profile.d/jdk11.sh #변경 사항 저장

 

4) 적용 확인

echo $JAVA_HOME #출력 결과가 /usr/local/jdk-11이어야 합니다.

java -version
#openjdk 11 2018-09-25
#OpenJDK Runtime Environment 18.9 (build 11+28)
#OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)