Java components needed to run a variety of applications and web sites, so virtually every computer user is confronted with the need of the installation of this platform. Of course, different operating systems, the principle of the task is different, but the Linux distributions it is always the same, and we’d like to tell you how to install Java in Ubuntu. The owners of other assemblies will only need to repeat the instructions given the syntax of the system.
Install Java JRE / JDK in Linux
Today, we offer different options for installation of the Java libraries because they will be most useful and applicable in certain situations. For example, if you do not want to use third party repositories or want to put some Java nearby, then you need to use a separate option. However, let’s take a closer look at them all.
First, it is recommended to check the updates to the system repositories and the current version of Java, even if it is present in the OS. This is all done through the standard console:
sudo apt-get update.
java-versionto see information about the installed Java.
Method 1: Official repositories
The simplest method is to use the official repository to download Java, which is unloaded there by the developers. You have to register a few commands to add all the necessary components.
sudo apt-get install default-jdkand then click on Enter.
sudo apt-get install default-jre.
sudo apt-get install icedtea-plugin.
sudo apt-get install default-jdk-doc.
Though this method is quite simple, it is not suitable for the installation of the latest Java libraries as they are not recently laid out in the official repository. That’s why we offer you to familiarize yourself with the following installation configurations.
Method 2: The Webupd8 Repository
There is a custom store called Webupd8, which has a script that compares the current Java version from the one on the Oracle website. This method of installation is useful to those who wish to install the newer 8 compiling it (the latest available in the repository Oracle).
sudo add-apt-repository ppa:webupd8team/java.
sudo apt-get update.
sudo apt-get install oracle Java 8 at-installer.
At the end of the process you will be available to the team to install any of the versions —
sudo apt-get install oracle-java7-installer, where java7 — version Java. For example, you can register
To get rid of unnecessary installers, use the command
sudo apt-get remove oracle Java 8 at-installerwhere Java 8 at version Java.
Method 3: Update using Webupd8
Above, we talked about installing assemblies by using a custom repository Webupd8. Thanks to the repository, you can upgrade Java to the latest just by script comparison.
sudo update-javaand then click on Enter.
sudo apt-get install update-javato install updates in the event of their finding.
Method 4: Manual install
Perhaps this method is the most heavy of those that we reviewed in this article, but it will allow you to obtain the necessary version of Java without using third-party repositories, and other additional components. For this purpose you will need any available browser and “Terminal”.
cd /home/user/folder, where user is the user name and folder is the folder where the archive is stored.
sudo mkdir -p /usr/lib/jvm.
sudo tar-xf jdk-11.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvmwhere jdk-11.0.2_linux-x64_bin.tar.gz — the name of the archive.
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.8.0/bin/javaws 1
One of several alternative paths may not exist, depending on the chosen version of Java.
sudo update-alternatives --config java, find Java version, check its number and write to the console.
sudo update-alternatives --config javac.
sudo update-alternatives --config javaws.
As you can see, the methods of installation of Java in Linux operating system there are quite a number, so each user will find a suitable option. If you are using a specific distribution, and these methods do not work, carefully review that appears in the error and use the official sources to solve the problem.