Install Java 11 and Java 8 on Linux - Coding Bot

Like Us On Facebook

Follow Us On Twitter

Drop Down Menu

Sunday, 10 February 2019

Install Java 11 and Java 8 on Linux

Hello friends,

As many of you must be knowing that Oracle officially ended the support for Java 8 in January this year. What this means for you? You get to try your hands on the latest JDK, which is 11.0.2 as of now. I will cover practical daily-code uses of Java 11 in a separate post soon. But till that time, let's discuss how to install Java 11 on your Linux distro. 

Now since many of your applications might still be using Java 8 and switching to Java 11 on production might not sound the best idea to your manager. This leaves you to find a way to install multiple Java versions on your machine and be able to switch between them in real-time.



In this post I'll share the steps to install Java 8 and Java 11 on your Linux machine and you can find how to switch between these two installations in this post -> How to switch between Java versions on Linux. 


I won't be sharing the steps to do the same on Windows OS as it is pretty straight forward, just download the official .exe JDK file from Oracle's website and run it. At max you would need to update the JAVA_HOME environment variable.

Step 1:

Add the following repository:
sudo add-apt-repository ppa:webupd8team/java

Step 2:

For Java 8:
sudo apt-get update

sudo apt install oracle-java8-installer

For Java 11:
sudo apt update

sudo apt install oracle-java11-installer

Step 3:

During the above process, the installer will ask for your consent to accept the conditions and after you provide it, it'll start downloading the official Java 8/Java 11 tar from Oracle's website. After it's done, you can check the current java version using this command:
java -version

Step 4:

If you want to make Java 8/Java 11 as your default java version, run the following command:

For Java 8:
sudo apt install oracle-java8-set-default

For Java 11:
sudo apt install oracle-java11-set-default

So now you have both the Java versions installed on your machine. You can always check which version is being currently used by java --version command in terminal.

That's all for now, I'll soon share the steps to switch between these two versions. Till then adios!