ubuntu20.04安装jdk

一 jdk

1.1 下载jdk

~# wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz

1.2 安装jdk

~# tar xf jdk-17_linux-x64_bin.tar.gz -C /usr/local/
~# ln -sv /usr/local/jdk-17.0.1/ /usr/local/jdk
'/usr/local/jdk' -> '/usr/local/jdk-17.0.1/'

1.3 设置环境变量

~# cat /etc/profile

export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

1.4 验证版本信息

~# java --version
java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

二 openjdk

2.1 下载openjdk

~# wget https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_linux-x64_bin.tar.gz

2.2 安装openjdk

~# tar xf openjdk-17_linux-x64_bin.tar.gz -C /usr/local/
~# ln -sv /usr/local/jdk-17.0.1/ /usr/local/jdk
'/usr/local/jdk' -> '/usr/local/jdk-17.0.1/'

2.3 设置环境变量

~# cat /etc/profile

export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

2.4 验证版本信息

~# java -version
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-39)
OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)

 

posted @ 2021-11-23 21:47  小吉猫  阅读(517)  评论(0编辑  收藏  举报