Ubuntu 22.04上解压安装JDK8

当前使用web8源的方式已经失效了,还是需要手动解压缩安装。

1 下载
https://www.oracle.com/hk/java/technologies/javase/javase8-archive-downloads.html
下载 jdk-8u202-linux-x64.tar.gz

2 解压缩

sudo mkdir /usr/java
sudo tar -xf ./jdk-8u202-linux-x64.tar.gz -C /usr/java

3 修改环境变量

# /etc/environment
PATH="...:/usr/java/jdk1.8.0_202/bin"
JAVA_HOME="/usr/java/jdk1.8.0_202"
CLASSPATH=.:/usr/java/jdk1.8.0_202/lib

4 设置默认命令

source ~/.bashrc

sudo update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_202/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_202/bin/javac 300
sudo update-alternatives --install /usr/bin/javap javap /usr/java/jdk1.8.0_202/bin/javap 300
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/java/jdk1.8.0_202/bin/javadoc 300
sudo update-alternatives --install /usr/bin/jps jps /usr/java/jdk1.8.0_202/bin/jps 300

 

Leave a Reply

Your email address will not be published. Required fields are marked *