Install and manage JDK

List installed configurations
update-java-alternatives -l
Select default configurations
update-alternatives --config java
Install open-jdk 8
sudo apt install openjdk-8-jdk

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

Install open-jdk X
sudo apt install openjdk-X-jdk
Install LATEST open-jdk
sudo apt install default-jdk
Install 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

Leave a Reply