OpenJDK卸载java jdk
[root@localhost ~]# java -version
openjdk version "1.8.0_65"
OpenJDK RuntimeEnvironment (build 1.8.0_65-b17)
OpenJDK 64-Bit ServerVM (build 25.65-b01, mixed mode)
[root@localhost ~]# rpm -qa | grep java
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
tzdata-java-2015g-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
[root@localhost ~]# rpm -qa | grep jdk
java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
rpm-e icedtea-web-1.6.1-4.el7.x86_64
rpm-e java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
rpm-e java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
rpm-qa | grep java | xargs rpm -e --nodeps
JDK官方下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html
cd /home/
wget http://mirrors.linuxeye.com/jdk/jdk-8u112-linux-x64.tar.gz
tar -xvf jdk-8u112-linux-x64.tar.gz -C /usr/local/
ln -s /usr/local/jdk1.8.0_112/ /usr/local/jdk
vim /etc/profile
#/etc/profile
# Systemwide environment and startup programs, for login setup
# Functionsand aliases go in /etc/bashrc
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=/usr/local/jdk/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/nginx/sbin:$JAVA_HOME/bin
方法2.
#vi /etc/profile.d/java.sh
java.sh 内容
1.方式
JAVA_HOME=/usr/local/jdk
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
2.方式
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
java-version
echo $JAVA_HOME
echo$CLASSPATH
echo$PATH