安装OpenJDK8
sudo apt-get install openjdk-8-jdk
配置Java环境变量
sudo vim /etc/profile
在profile末尾添加以下内容:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
添加后保存并退出,用java -version
查看是否配置成功
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
原文地址:https://blog.csdn.net/EahanZhang/article/details/88085561