install openjdk 12 | zuhdi.org

Install OpenJDK 12

Environment

  • Debian 9.7 x64
  • OpenJDK

Excerpt https://jdk.java.net/

Log 2019 / 06

1. Pre

root@athos:~# apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade

wget -q https://download.java.net/java/GA/jdk12.0.1/\
69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz

root@athos:~# wget -q https://download.java.net/java/GA/jdk12.0.1/\
> 69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz

wget -q https://download.java.net/java/GA/jdk12.0.1/\
69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz.sha256

root@athos:~# wget -q https://download.java.net/java/GA/jdk12.0.1/\
> 69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz.sha256

2. Verify Signature

echo $(cat openjdk-12.0.1_linux-x64_bin.tar.gz.sha256) \
  openjdk-12.0.1_linux-x64_bin.tar.gz | sha256sum -c -

root@athos:~# echo $(cat openjdk-12.0.1_linux-x64_bin.tar.gz.sha256) \
>   openjdk-12.0.1_linux-x64_bin.tar.gz | sha256sum -c -
openjdk-12.0.1_linux-x64_bin.tar.gz: OK

3. Install OpenJDK 12

root@athos:~# mkdir /usr/lib/jvm/

root@athos:~# tar -xf openjdk-12.0.1_linux-x64_bin.tar.gz -C /usr/lib/jvm/

JAVA_HOME=/usr/lib/jvm/jdk-12.0.1/
PATH=$PATH:$JAVA_HOME/bin
echo "export JAVA_HOME=$JAVA_HOME" >> ~/.bashrc
echo "export PATH=$PATH" >> ~/.bashrc
source ~/.bashrc

root@athos:~# JAVA_HOME=/usr/lib/jvm/jdk-12.0.1/

root@athos:~# PATH=$PATH:$JAVA_HOME/bin

root@athos:~# echo "export JAVA_HOME=$JAVA_HOME" >> ~/.bashrc

root@athos:~# echo "export PATH=$PATH" >> ~/.bashrc

root@athos:~# source ~/.bashrc

root@athos:~# java -version
openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

update-alternatives --install /usr/bin/java java \
  /usr/lib/jvm/jdk-12.0.1/bin/java 0

root@athos:~# update-alternatives --install /usr/bin/java java \
>   /usr/lib/jvm/jdk-12.0.1/bin/java 0
update-alternatives: using /usr/lib/jvm/jdk-12.0.1/bin/java to provide 
  /usr/bin/java (java) in auto mode

update-alternatives --install /usr/bin/javac javac \
  /usr/lib/jvm/jdk-12.0.1/bin/javac 0

root@athos:~# update-alternatives --install /usr/bin/javac javac \
>   /usr/lib/jvm/jdk-12.0.1/bin/javac 0
update-alternatives: using /usr/lib/jvm/jdk-12.0.1/bin/javac to provide 
  /usr/bin/javac (javac) in auto mode

root@athos:~# update-alternatives --set java /usr/lib/jvm/jdk-12.0.1/bin/java

root@athos:~# update-alternatives --set javac /usr/lib/jvm/jdk-12.0.1/bin/javac

root@athos:~# update-alternatives --list java
/usr/lib/jvm/jdk-12.0.1/bin/java

root@athos:~# update-alternatives --list javac
/usr/lib/jvm/jdk-12.0.1/bin/javac

root@athos:~# update-alternatives --config java
There is 1 choice for the alternative java (providing /usr/bin/java).

  Selection    Path                              Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/jdk-12.0.1/bin/java   0         auto mode
* 1            /usr/lib/jvm/jdk-12.0.1/bin/java   0         manual mode

Press <enter> to keep the current choice[*], or type selection number: 1

Hugo. Malte Kiefer & Zuhdi Najib.