Useful Tips

Uncle Raji's Notes

Pin
Send
Share
Send
Send


Java components are required to run a wide variety of applications and websites, so almost every computer user is faced with the need to install this platform. Of course, in different operating systems the principle of the task is different, but for Linux distributions it is always about the same, but we would like to tell how Java is installed in Ubuntu. Owners of other assemblies will only need to repeat the instructions given, taking into account the syntax of the system.

Install Java JRE / JDK on Linux

Today we suggest that you familiarize yourself with the different options for installing Java libraries, since all of them will be most useful and applicable in certain situations. For example, if you do not want to use third-party repositories or if you want to put several Java nearby, then you need to use a separate option. However, let's take a closer look at all of them.

First, it is recommended that you check for system storage updates and find out the current version of Java, if any, in the OS. All this is done through the standard console:

  1. Open the menu and run "Terminal".

Enter the command sudo apt-get update.

Enter the password from your account to gain root access.

If you receive a notification similar to the one below, it means that Java is not available in your OS.

Method 1: Official Repositories

The easiest method is to use the official repository to download Java, which the developers uploaded there. You only need to register a few commands to add all the necessary components.

    Run "Terminal" and write sudo apt-get install default-jdk there, and then click on Enter.

Now add the JRE by typing the command sudo apt-get install default-jre.

The browser plug-in that is added via sudo apt-get install icedtea-plugin will also work.

If you are interested in obtaining documentation regarding added components, download them with the sudo apt-get install default-jdk-doc command.

Although this method is quite simple, it is not suitable for installing the latest Java libraries, since they have not been laid out in the official repository recently. That is why we suggest that you familiarize yourself with the following installation options.

Method 2: Webupd8 Repository

There is a user repository called Webupd8, which has a script comparing the current version of Java with the one on the Oracle site. This installation method is useful for those who want to install a newer release 8 (the last available in the Oracle repository).

    In the console, type sudo add-apt-repository ppa: webupd8team / java.

Be sure to include your password.

Confirm the add operation by clicking on Enter.

Expect file downloads to complete without closing "Terminal".

Update system storage with the sudo apt-get update command.

Now you should add the graphical installer by typing sudo apt-get install oracle-java8-installer.

Accept the license agreement to configure the package.

Agree to add new files to the system.

At the end of the process, a command will be available for you to install absolutely any version - sudo apt-get install oracle-java7-installer, where java7 - Java version. For example, you can write java9 or java11.

The sudo apt-get remove oracle-java8-installer command will help get rid of unnecessary installers, where java8 - Java version.

Method 3: Upgrade Using Webupd8

Above, we talked about installing assemblies by using the Webupd8 custom repository. Thanks to the same repository, you can update the Java version to the latest one just by means of a comparison script.

  1. Repeat the first five steps from the previous instructions if you have not already done these steps.
  2. Type in the command sudo update-java and then click on Enter.

Use the sudo apt-get install update-java command to install updates if they are found.

Method 4: Manual Installation

Perhaps this method is the hardest of those that we examined in this article, but it will allow you to get the necessary version of Java without using third-party repositories and other additional components. To accomplish this task, you will need any available browser and "Terminal".

    Via a web browser, go to the official Oracle page to download Java, where click on "Download" or select any other necessary version.

Below are several packages with libraries. We recommend downloading the format archive tar.gz.

Go to the archive folder, right click on it and select "Properties".

Remember the location of the package, because you have to go to it through the console.

Run "Terminal" and run the command cd / home / user / folder, where user - username, and folder - name of the archive storage folder.

Create a folder to unzip the archive. Usually all components are placed in jvm. Creating a directory is done by typing sudo mkdir -p / usr / lib / jvm.

Unpack the existing sudo tar -xf jdk-11.0.2_linux-x64_bin.tar.gz -C / usr / lib / jvm archive into the created folder jdk-11.0.2_linux-x64_bin.tar.gz - name of the archive.

To add system paths, you need to enter the following commands sequentially:

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 alternative path may not exist, depending on the version of Java you choose. It remains only to carry out the configuration of each path. First, run sudo update-alternatives --config java, find the appropriate version of Java, check its number and write to the console.

Repeat the same step with sudo update-alternatives --config javac.

Then configure the last path through sudo update-alternatives --config javaws.

  • Check the success of the changes by recognizing the active version of Java (java -version).
  • As you can see, there are a large number of methods for installing Java in the Linux operating system, so each user will find a suitable option. If you use a specific distribution kit and the above methods do not work, carefully study the errors displayed in the console and use official sources to solve the problem.

    Thank the author, share the article on social networks.

    Blog Archive

    • ►2019 (5)
      • ►June (2)
      • ►May (1)
      • ►March (1)
      • ►January (1)
    • ▼2018 (15)
      • ►December (2)
      • ▼ November (1)
        • Manual installation of Oracle Java 8 on Debian Linux.
      • ►October (2)
      • ► September (1)
      • ►July (1)
      • ►June (1)
      • ►May (2)
      • ►April (3)
      • ►February (1)
      • ►January (1)
    • ►2017 (20)
      • ►December (1)
      • ►November (2)
      • ►October (1)
      • ►September (3)
      • ►August (3)
      • ►June (1)
      • ►May (1)
      • ►April (1)
      • ►March (1)
      • ►February (4)
      • ►January (2)
    • ►2016 (15)
      • ►December (4)
      • ►October (1)
      • ►August (1)
      • ►July (2)
      • ►June (1)
      • ►April (3)
      • ►February (1)
      • ►January (2)
    • ►2015 (10)
      • ►December (1)
      • ►November (2)
      • ► September (1)
      • ►August (2)
      • ►July (1)
      • ►June (2)
      • ►April (1)
    • ►2014 (16)
      • ►December (1)
      • ►November (3)
      • ►October (1)
      • ► September (1)
      • ►August (2)
      • ►July (2)
      • ►May (1)
      • ►April (1)
      • ►February (4)
    • ►2013 (11)
      • ►December (2)
      • ►October (2)
      • ►August (1)
      • ►July (1)
      • ►June (1)
      • ►April (1)
      • ►March (1)
      • ►January (2)
    • ►2012 (24)
      • ►December (1)
      • ►November (2)
      • ►October (1)
      • ► September (1)
      • ►July (1)
      • ►June (4)
      • ►May (2)
      • ►April (2)
      • ►March (6)
      • ►February (2)
      • ►January (2)
    • ►2011 (14)
      • ►December (2)
      • ►October (2)
      • ►September (2)
      • ►August (5)
      • ►July (2)
      • ►February (1)
    • ►2010 (29)
      • ►December (1)
      • ►June (1)
      • ►May (3)
      • ►April (10)
      • ►March (7)
      • ►February (4)
      • ►January (3)
    • ►2009 (38)
      • ►December (6)
      • ►November (4)
      • ►October (4)
      • ► September (8)
      • ►August (2)
      • ►July (2)
      • ►May (2)
      • ►April (1)
      • ►March (5)
      • ►February (2)
      • ►January (2)
    • ►2008 (50)
      • ►December (4)
      • ►November (6)
      • ►October (7)
      • ►September (15)
      • ►August (14)
      • ►July (1)
      • ►June (2)
      • ►May (1)

    Manual installation of Oracle Java 8 on Debian Linux.

    Now there will be essentially a free translation of the manual, which is on the Debian website. I’m writing down more for myself if I suddenly want to install JRE / JDK remotely from a burning tank, having only the ssh client, browser and little traffic at hand.
    I took something from the management, spied something, I thought of something myself.

    The tools you need:

    1. Utility "make-jpkg"from package"java-package",
    2. Not too old browser that can execute JavaScript and work with sites via HTTPS,
    3. SSH client.
    If everything is there, then you can proceed.

    We go to the remote server via SSH and open the browser.
    On the remote server, install "java-package":

    In the browser, open links to the JRE and JDK.
    On both pages, you must accept the license agreement to make the links available:

    We pass to the SSH client.

    For the file to download successfully, you need to add some headers to the request to simulate the acceptance of the license agreement

    If everything is done correctly, then the files "should appear in the directoryjre-8u191-linux-x64.tar.gz"and"jdk-8u191-linux-x64.tar.gz".
    Of these, you need to make deb packages for installation. This is done as follows:


    We perform a similar procedure with the second file.

    New files should appear in the directory "oracle-java8-jre_8u191_amd64.deb"and"oracle-java8-jdk_8u191_amd64.deb".

    Now they need to be installed with this command:


    If there are messages about unsatisfied dependencies, then you need to reinstall the necessary with the following command:


    In order for everything described above to be done automatically, you can use the webupd8team PPA repository. A guide to adding it is available here.

    Method number 1.

    Short and fast option (if you have x86_64),
    where the .deb package is already prepared in advance by me, posted on the network, and it remains only to download and install it:

    1) Download the package.
    2) We execute 4 commands in the terminal:


    3) We restart the browser and enjoy the time saved.
    Unless of course you have a 64-bit version of the pangolin.

    Method number 2, from start to finish.

    1) We go to the Java SE download site, and download the package (.rpm), according to our architecture:
    Linux x86 (32-bit)
    Linux x64 (64-bit)
    2) Install alien, in fact it is a package converter that repackages downloaded .rpm packages to
    we need the .deb format, with its tricks.

    3) We set the "alien" on the downloaded rpm.

    At this stage, a .deb package will be generated in the same directory.
    4) Further on the thumb, we install the package, create symlinks and enjoy life.


    I’ll make a reservation right away that I don’t stand on the fact that OpenJDK is to blame for everything, but experiments were made
    on freshly installed 12.04 and all problems were resolved after installing the proprietary version.

    Install JRE / JDK in default configuration

    The easiest way to install Java is to use the version distributed with Ubuntu. This method will install OpenJDK 8, the latest and recommended version.

    First, update the list of packages:

    Then install Java. This command will install the Java Runtime Environment (JRE):

    There is a second version of the default Java installation: JDK (Java Development Kit). Installing the JDK is usually necessary when you plan to compile Java programs or when the software you use explicitly requires a JDK.

    You can install the JDK with the following command:

    Install Oracle JDK

    To install the Oracle JDK, which is the official version of Java distributed by Oracle, you need to follow a few additional steps.

    First, add the PPA to Oracle, then update the list of packages:

    Next, depending on which specific version you want to install, run one of the following commands:

    Oracle JDK 9

    This version is in developer preview state and is scheduled for release in March 2017. We do not recommend installing this version because it may contain errors and security issues. You can learn more about Java 9 on the official JDK 9 website.

    To install JDK 9, run the following command:

    Java Versioning

    At the same time, more than one version of Java can be installed on the same server. You can use the update-alternatives utility to set the default version and create symbolic links to different versions.

    The result of this command will be a conclusion similar to the one presented below. In this example, we see that all of the above versions of Java have been installed.

    You can select the default version number of Java. The same can be done for the Java compiler (javac), the documentation generator (javadoc), the JAR signing tool (jarsigner), and other tools. Enter the following command, replacing command with the name of the required tool:

    Setting the environment variable JAVA_HOME

    Many programs, including Java servers, use the JAVA_HOME environment variable to determine where Java is installed. To set this variable, we need to understand where Java was installed. To do this, you can run the following command:

    Copy the necessary Java installation, and then open / etc / environment in the nano text editor or any other text editor of your choice.

    Add the following line to the end of this file, replacing the path highlighted in red by the path you copied earlier to the required version of Java.

    Save the file, close it and apply the changes with the following command:

    You can check your changes with the command:

    This command should return the path to your version of Java.

    Pin
    Send
    Share
    Send
    Send