下载、解压JDK
首先下载压缩包
wget https://download.java.net/openjdk/jdk8u41/ri/openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
然后解压
tar -zxvf openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
配置JAVA_HOME环境变量
# 打开环境变量文件
vim .bashrc
# 子文件末尾追加
export JAVA_HOME=/home/user_name/java-se-8u41-ri
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=${JAVA_HOME}/jre/bin:$PATH
# source一下,重新加载环境变量
source .bashrc
检查环境安装是否成功
输入:
java -version
输出:
openjdk version "1.8.0_41"
OpenJDK Runtime Environment (build 1.8.0_41-b04)
OpenJDK 64-Bit Server VM (build 25.40-b25, mixed mode)