假设java安装包在/home目录下
1. mkdir -p /usr/java
2. tar xzvf /home/jdk-8u271-linux-x64.tar.gz -C /usr/java/
3. vi /etc/profile
追加
export JAVA_HOME=/usr/java/jdk1.8.0_271
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH
4. source /etc/profile