CentOS7 Java 설치



1. 설치 된 자바 버전 확인


yum list installed | grep java



2. JDK 설치


yum install java-1.8.0-openjdk -y



3. 환경 변수 등록


readlink -f /usr/bin/java

# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre/bin/java

vi ~/.bashrc

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

source ~/.bashrc

# 우분투의 경우

vi ~/.bashrc # vi ~/.zshrc

export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export PATH=$PATH:$JAVA_HOME/bin

source ~/.bashrc # source ~/.zshrc



4. java version 확인


java -version



5. wget 설치


yum install wget -y