参考:https://www.linuxidc.com/Linux/2016-09/135556.htm
1.下载jdk
首先创建安装包放置位置
mkdir -p /usr/local/java
然后可以通过wget + url的方式直接下载,也可以先下载到windows系统中再通过xshell上传或ftp上传,注意oracle的下载需要先登录才可以,这里有jdk8的下载地址
2.解压压缩包
tar -zxvf jdk-8u171-linux-x64.tar.gz
解压后目录为jdk1.8.0_171
3.配置环境变量
vi /etc/profile
在文件尾部添加如下配置:
export JAVA_HOME=/usr/local/java/jdk1.8.0_171 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
使配置生效
source /etc/profile
4.检查是否配置成功
java -version
出现版本信息表示配置成功