1.下载并上传并解压安装包
下载安装包上传到/usr/local目录
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.配置环境变量
vi /etc/profile
在文件末尾添加环境变量信息
export JAVA_HOME=/usr/local/java/jdk1.8.0_211 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export ZX_HOME=/usr/local/xz export PATH=$PATH:$JAVA_HOME/bin:$PATH:/usr/local/mongodb-linux-x86_64-3.0.1/bin:$PATH:$ZX_HOME/bin:$PATH:$P
3.使配置文件生效
. /etc/profile
4.查看按照是否成功
java -version