I will put in one place all the information:
https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
- Download:
jdk-8u251-linux-x64.tar.gz
Login with oracle account
Uncompress it in /opt
sudo cp ~/Desktop/jdk-8u251-linux-x64.tar.gz /opt
cd /opt
sudo tar xfz jdk-8u251-linux-x64.tar.gz
sudo ln -s jdk1.8.0_251 java
- Make
java
binary point to desired SDK
5.1. Install alternative
sudo update-alternatives --install /usr/bin/java java /opt/java/bin/java 2
5.2. Activate it
sudo update-alternatives --config java
5.3. Select the entry added in step 4.1.
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-14-openjdk-amd64/bin/java 1411 auto mode
1 /opt/java/bin/java 2 manual mode
2 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
3 /usr/lib/jvm/java-14-openjdk-amd64/bin/java 1411 manual mode
In this case type 1
and press Enter
5.4. Test
Type:
java -version
Expected output similar to:
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
- Make
javac
binary point to desired SDK
6.1. Install alternative
sudo update-alternatives --install /usr/bin/javac javac /opt/java/bin/javac 2
6.2. Activate it
sudo update-alternatives --config javac
6.3. Select the entry added in step 6.1.
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-14-openjdk-amd64/bin/javac 1411 auto mode
* 1 /opt/java/bin/javac 2 manual mode
2 /usr/lib/jvm/java-14-openjdk-amd64/bin/javac 1411 manual mode
In this case type 1
and press Enter
6.4. Test
Type:
javac -version
Expected output similar to:
javac 1.8.0_251
if the output is similar to the output of "java -version", make sure you've written the correct command in section 6.1 with the missing "c" of the original post.