ubuntu小技巧

ubuntu22.04安装jdk8(jdk1.8)步骤

#apt-get install openjdk-8-jdk

# which java
/usr/bin/java

#readlink -f /usr/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
去掉后面的/bin/java,设置环境变量:

echo 'export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
source /etc/profile

# java -version
openjdk version "1.8.0_412"