安装jdk
64bit
# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u121- b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz"
# tar xzf jdk-8u121-linux-x64.tar.gz
32bit
# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-i586.tar.gz"
# tar xzf jdk-8u121-linux-i586.tar.gz
用 Alternatives安装java
# cd /opt/jdk1.8.0_121/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_121/bin/java 2
# alternatives --config java
There are 1 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /opt/jdk1.8.0_121/bin/java
Enter to keep the current selection[+], or type selection number: 1
配置jar命令
# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_121/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_121/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_121/bin/jar
# alternatives --set javac /opt/jdk1.8.0_121/bin/javac
配置java环境
# export JAVA_HOME=/opt/jdk1.8.0_121
# export JRE_HOME=/opt/jdk1.8.0_121/jre
# export PATH=$PATH:/opt/jdk1.8.0_121/bin:/opt/jdk1.8.0_121/jre/bin
检测java
# java -version
参考自:https://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/#
网友评论