//先跟新可用安装信息

apt-get update

//查看可以安装的jdk版本

apt-cache search jdk

//会显示如下内容:

openjdk-8-dbg – Java runtime based on OpenJDK (debugging symbols)
openjdk-8-demo – Java runtime based on OpenJDK (demos and examples)
openjdk-8-doc – OpenJDK Development Kit (JDK) documentation
openjdk-8-jdk – OpenJDK Development Kit (JDK)
openjdk-8-jdk-headless – OpenJDK Development Kit (JDK) (headless)
openjdk-8-jre – OpenJDK Java runtime, using Hotspot JIT
openjdk-8-jre-headless – OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-8-jre-zero – Alternative JVM for OpenJDK, using Zero/Shark
openjdk-8-source – OpenJDK Development Kit (JDK) source files
openjdk-8-jre-dcevm – Alternative VM for OpenJDK 8 with enhanced class redefinition

//选择需要安装的版本:

apt-get install openjdk-8-jdk

//等待安装完成,验证是否完成安装

java -version

//显示如下信息,确定完成安装。

openjdk version “1.8.0_232”
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-1~deb9u1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)