在 Ubuntu 2020.04 上安装 Java

·  阅读 155

使用 apt 安装 OpenJDK

Java 11 is the long term support version.

sudo apt-get update
sudo apt-get install openjdk-11-jdk
复制代码

Java 8 is the previous long term support version.

sudo apt-get update
sudo apt-get install openjdk-8-jdk
复制代码

设置使用的 Java 版本

When the system has various versions of JDK, we need the following commands to select which version we want to use in our environment.

sudo update-alternatives --config java
复制代码

JAVA_HOME 环境变量配置

Sometimes, JAVA_HOME is used to prevent where Java is installed.

# Add following into /etc/environment or ~/.bashrc ~/.zshrc
# for example
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
# check config
echo $JAVA_HOME
复制代码

END ( ̄▽ ̄)/

分类:
后端
标签:
分类:
后端
标签:
收藏成功!
已添加到「」, 点击更改