Install and manage JDK

Installation

Open-JDK 8

sudo apt install openjdk-8-jdk

Open-JDK X

sudo apt install openjdk-X-jdk

Latest Open-JDK

sudo apt install default-jdk

Oracle-jdk 8

Download the Linux x64 compressed archive for the version you want. Then:

Make a directory:

sudo mkdir -p /usr/lib/jvm

Extract to that directory:

sudo tar zxvf jdk-version-linux-x64.tar.gz -C /usr/lib/jvm

Configure the new version for OS:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_version/bin/java" 1

Set the new configuration as default (optional)

sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_version/bin/java

Check the changes, close the shell, open a new one and run the command:

java -version

Management

List installed versions

update-java-alternatives -l

Select default version

update-alternatives --config java

You may install any specific version with the following command (replace X with your

Leave a Reply