1.下载安装包
2.新建java目录
sudo mkdir /usr/local/java
3.解压安装包到目录下
sudo tar -zvxf jdk-8u161-linux-x64.tar.gz -C /usr/local/java/
4.修改profile,进行配置
sudo vim /etc/profile
#set Java environment
export JAVA_HOME=/usr/local/java/jdk1.8.0_161
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
5.source一下生效
source /etc/profile
6.查看是否已安装
jiqing@ThinkPad:/usr/local/java$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)