yum list installed | grep java
(2)卸载自带的openJDK
yum -y remove R-java R-java-devel java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64 java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-headless.x86_64 tzdata-java.noarch
(3)解压jdk文件并且放置在/usr/local/java/jdk下面
tar -zxvf jdk-8u121-linux-i586.tar.gz
mv jdk1.8.0_121 jdk
cd /usr/local
mkdir java
cd ~
mv jdk /usr/local/java/
cd /usr/local/java/
(4)配置环境变量
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
source /etc/profile
(5) 设置默认的java
update-alternatives --remove-all "java"
update-alternatives --remove-all "javac"
update-alternatives --remove-all "javaws"
update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk/bin/javaws" 1
update-alternatives --set java /usr/local/java/jdk/bin/java
update-alternatives --set javac /usr/local/java/jdk/bin/javac
update-alternatives --set javaws /usr/local/java/jdk/bin/javaws
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/u011596455/article/details/69665821