创建java目录、解压java压缩包到新建目录
mkdir -p /usr/local/java && tar -zxvf /home/soft/jdk-8u291-linux-x64.tar.gz -C /usr/local/java/
编辑/etc/profile,并在文件末尾添加以下信息
export JAVA_HOME=/usr/local/java/jdk1.8.0_291
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
使文件生效
source /etc/profile
创建java软连接
ln -s /usr/local/java/jdk1.8.0_291/bin/java /usr/bin/java