1.下载安装包
下载链接:https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html
2,创建安装目录
mkdir /usr/local/java
3,解压至安装目录
tar xf jdk-8u151-linux-x64.tar.gz -C /usr/local/java/
4,设置环境变量
vim /etc/profile
#末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_151
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
5,使环境变量生效(至此安装完成)
source /etc/profile
6,查看版本
[root@web-2 ~]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
网友评论