How to install Java on the different Linux distributions?

oracle-java-11

Java is a programming language and at the same time an important platform that runs on most modern operating systems.

It is used for various purposes and is an almost essential complement to the execution and operation of various tools.

OpenJDK is an open-source community version of Java . It is widely used because it is included by default in Ubuntu and many other Linux distributions.

However, it cannot be used to develop commercial applications. Java is an object-oriented programming language owned by Oracle. It is a compiled language with its own rules, widely used in educational and professional settings.

Due to its licensing, Java is not installed by default on most Linux distributions. Therefore, to have Java on your distribution, you will need to install it yourself.

Java is compatible with Linux, this means that it is possible to run and build applications from your favorite distribution.

Installing Java on the different Linux distributions

As mentioned, the installation of Java on different Linux distributions is different for each one , so you should follow the instructions we shared with you, according to the Linux distribution you are using.

To install Oracle Java 11 on Ubuntu 18.10 and its derivatives and still be able to automatically receive future updates from it, we must do the following:

Ubuntu and derivatives

For Ubuntu 18.10, Ubuntu 18.04 and derivatives, we will open a terminal on the system ( you can use the keyboard shortcut CTRL + ALT + T) and in the terminal we will type the following command to add the repository to the system:

sudo add-apt-repository ppa:linuxuprising/java

Once this is done, we must refresh the repositories and packages with the command:

sudo apt-get update

Finally, we can install Java with:

sudo apt install oracle-java11-installer

Debian

If you are a Debian user or a Debian-based distribution such as Neptune OS, Deepin OS, and others, you must open a terminal and perform a few steps before directly installing Java on your system.

java-11

On the terminal we are going to type:

sudo -i
apt install wget libasound2 libasound2-data

Done this now we are going to download the Java 11 deb package with:

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/11+28/55eed80b163941c8885ad9298e6d786a/jdk-11_linux-x64_bin.deb

Finally we install with:

dpkg -i jdk-11_linux-x64_bin.deb

Having done this, we will now set Java 11 as the default version:

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11/bin/java 2
update-alternatives --config java

Arch Linux and derivatives

In the case of those who are users of Arch Linux, Antergos, Manjaro or any other distribution derived from Arch Linux, they can perform the java installation in a fairly simple way.

All you need to do is have the AUR repository added to your pacman.conf file and have a wizard to install AUR packages on your system.

If you don't have one, you can use the one I recommend in the following post.

Now you simply have to open a terminal and execute the following command:

yay -S jdk

And that's it, you just have to wait for the compilation to finish and it will ask you to enter your password at the end to complete the installation.

RHEL, CentOS, Fedora, openSUSE and derivatives

For those who use distributions that support RPM packages, we can install Java on our system using the following package , which we will download using our terminal:

wget "https://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.rpm?AuthParam=1540738418_ef8759a34917876432dbb9d668d4b5e4" -O java11.rpm

Now , to begin the installation, in the unique case of openSUSE, we will install the package with:

sudo zypper install java11.rpm

Finally, to install on Fedora, Red Hat and their derivatives, you can do so with the following command:

sudo yum localinstall java11.rpm

Or with this command they can also do it:

sudo dnf install java11.rpm

How to check if java was installed correctly?

After successfully installing Java on our system, we can verify that we have Java version 11 installed using the following command:

java --version


Add as preferred source in Google