linux(centos)下安装java jdk----源码安装

1.下载并解压源码包(http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html)

wget http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1515723490_d67c6d22eb5101a0d4e9dbf0f7cf0bd4
mv jdk-8u151-linux-x64.tar.gz\?AuthParam\=1515723490_d67c6d22eb5101a0d4e9dbf0f7cf0bd4 jdk-8u151-linux-x64.tar.gz
tar zxvf jdk-8u151-linux-x64.tar.gz
mv jdk1.8.0_151/ /usr/local/java/
2.配置环境变量

JAVA_HOME=/usr/local/java/jdk1.8.0_151
JRE_HOME=/usr/local/java/jdk1.8.0_151/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
3.执行source /etc/profile 让其环境变量配置生效

4.测试: java -version






你可能感兴趣的:(java)