CentOS / Redhat Java

# download
wget  wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm" # 여기서 link URL 적어줌
 
# JDK 버전에 따라 파일명, 경로를 적당히 바꿔줄것
# install
sudo rpm -ivh jdk-8u161-linux-x64.rpm
 
# alternatives 등록.
sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_161/bin/java 20000
 
# set as default 화면에서 선택
sudo /usr/sbin/alternatives --config java
 
# 확인
java -version
 
# .bashrc 혹은 .bash_profile 에 환경변수 등록
export JAVA_HOME=/usr/java/default

Java Alternatives 명시적 명령행 설정

sudo alternatives --set java /location/of/jdk1.6/bin/java