How to install Java on Linux

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:

  • Open the menu and run “Terminal”.
  • Enter the command sudo apt-get update.
  • Enter your account password to obtain root access.
  • After receiving packets, use the command java-versionto see information about the installed Java.
  • If you receive a notification that resembles the following, then Java in your OS are not available.
  • 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.

  • Run “Terminal” and write there sudo apt-get install default-jdkand then click on Enter.
  • Confirm adding files.
  • Now add the JRE by typing the command sudo apt-get install default-jre.
  • Do not interfere, and the browser plug-in that is added via sudo apt-get install icedtea-plugin.
  • If you are interested in receiving documentation with regards to the added components, load them with the command 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).

  • In the console enter sudo add-apt-repository ppa:webupd8team/java.
  • Be sure to specify your password.
  • Confirm the add operation by clicking on Enter.
  • Wait for it to complete downloading the file without closing the Terminal.
  • Update system repository command sudo apt-get update.
  • Now you will add graphical installer by typing sudo apt-get install oracle Java 8 at-installer.
  • Accept the license agreement for the package configuration.
  • Agree with adding new files to the system.
  • 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 java9 or java11.

    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.

  • Repeat the first five steps of the previous instructions, if you have not done these steps.
  • Enter the command sudo update-javaand then click on Enter.
  • Use the command sudo apt-get install update-java to 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”.

  • Using a web browser navigate to the official website of Oracle to download Java where click on “Download” or select any other desired version.
  • Below is some packages with libraries. We suggest to download the archive format tar.gz.
  • Go to the folder with the archive, click on it RMB and choose “Properties”.
  • Note the location of the package, because you have to navigate to it via the console.
  • Run “Terminal” and run the command cd /home/user/folder, where user is the user name and folder is the folder where the archive is stored.
  • Create a folder for unpacking the archive. Usually all the components are placed in the jvm. Create the directory by typing sudo mkdir -p /usr/lib/jvm.
  • Unpack the existing archive 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.
  • To add system paths, you will need to consistently enter the following command:

    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.

  • It remains only to make the configuration of each path. First, run sudo update-alternatives --config java, find Java version, check its number and write to the console.
  • Repeat the same action with sudo update-alternatives --config javac.
  • Then set up the latest path using sudo update-alternatives --config javaws.
  • Verify the success of implemented changes, active learning version of Java (java-version).
  • 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.

    Source: lumpics.ru

    (Visited 41 times, 1 visits today)