How to Install Oracle Java JRE in Linux Ubuntu

Table of contents:

How to Install Oracle Java JRE in Linux Ubuntu
How to Install Oracle Java JRE in Linux Ubuntu
Anonim

This tutorial covers installing Oracle Java 7 32-bit and 64-bit (current version number 1.7.0_40) JRE in the 32-bit and 64-bit Ubuntu Linux operating system. These instructions also work for Linux Mint and Debian. This article is conceived alone for those who want to install Oracle Java JRE on Debian and Linux systems such as Debian, Ubuntu and Linux Mint. With this method you will be only able to run Java programs without being able to develop and program them in Java. This article was born from the various requests of many users who wanted only know how to install Oracle Java JRE on an Ubuntu system. This article also includes a section for enabling Oracle Java JRE with browsers. These instructions will work for Debian, Ubuntu, and Linux Mint.

Steps

Install Oracle Java JRE on Ubuntu Linux Step 1
Install Oracle Java JRE on Ubuntu Linux Step 1

Step 1. Check if your Linux Ubuntu system is 32-bit or 64-bit

Open the terminal and run the following command below.

  • Type / Copy / Paste: 'file / sbin / init

    You will see on the monitor whether your Linux Ubuntu OS version is 32-bit or 64-bit

Install Oracle Java JRE on Ubuntu Linux Step 2
Install Oracle Java JRE on Ubuntu Linux Step 2

Step 2. Check if you have already installed Java on your system

To do this, run this Java command in the terminal.

  • Open the terminal and enter the following command:

    • Type / Copy / Paste:

      java -version

  • If you have OpenJDK installed on your system, you will see:

    • java version "1.7.0_15"

      OpenJDK Runtime Environment (IcedTea6 1.10pre) (6b15 ~ pre1-0lucid1)

      OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

  • So if you have OpenJDK installed on your system, it means that you have an unsuitable version of Java for this procedure.
Install Oracle Java JRE on Ubuntu Linux Step 3
Install Oracle Java JRE on Ubuntu Linux Step 3

Step 3. Completely remove OpenJDK / JRE from your system and create a directory for Oracle Java JRE

It will avoid conflicts and confusions between the various Java versions. For example, if you have OpenJDK / JRE installed on your system, remove it with the following command:

  • Type / Copy / Paste:

    sudo apt-get purge openjdk - / *

    This command will completely remove OpenJDK / JRE from your system

  • Type / Copy / Paste:

    sudo mkdir -p / usr / local / java

    This command will create a directory for the Oracle Java JDK and JRE binaries

Install Oracle Java JRE on Ubuntu Linux Step 4
Install Oracle Java JRE on Ubuntu Linux Step 4

Step 4. Download Oracle Java JRE for Linux

Make sure you choose the compressed binaries suitable to the 32-bit or 64-bit architecture of your system (with the tar.gz extension).

  • For example, if your system is 32-bit Linux Ubuntu, download the 32-bit Oracle Java binaries.
  • Instead, if your system is 64-bit Linux Ubuntu, download the 64-bit Oracle Java binaries.
  • Optional, Download the Oracle Java JDK / JRE documentation

    Select jdk-7u40-apidocs.zip

  • Important:

    64-bit Oracle Java binaries do not work on a 32-bit Ubuntu Linux operating system. Several errors will occur if you try to do this.

Install Oracle Java JRE on Ubuntu Linux Step 5
Install Oracle Java JRE on Ubuntu Linux Step 5

Step 5. Copy the files to / usr / local / java directory

Oracle Java files are often downloaded to: / home /"your_user_name"/ Downloads.

  • 32-bit Oracle Java installation instructions in 32-bit Ubuntu Linux system:

    • Type / Copy / Paste:

      cd / home /"your_user_name"/ Downloads

    • Type / Copy / Paste:

      sudo cp -r jre-7u45-linux-i586.tar.gz / usr / local / java

    • Type / Copy / Paste:

      cd / usr / local / java

  • 64-bit Oracle Java installation instructions on 64-bit Ubuntu Linux system:

    • Type / Copy / Paste:

      cd / home /"your_user_name"/ Downloads

    • Type / Copy / Paste:

      sudo cp -r jre-7u45-linux-x64.tar.gz / usr / local / java

    • Type / Copy / Paste:

      cd / usr / local / java

    Install Oracle Java JRE on Ubuntu Linux Step 6
    Install Oracle Java JRE on Ubuntu Linux Step 6

    Step 6. Run these commands with the downloaded Oracle Java tar.gz files

    Make sure you do this as a system administrator, so that the commands are executable for all users of the system. To open the terminal in administrator mode type "sudo -s", and you will be asked for your username and password.

    • 32-bit Oracle Java installation instructions in 32-bit Ubuntu Linux system:

      • Type / Copy / Paste:

        sudo chmod a + x jre-7u45-linux-i586.tar.gz

    • 64-bit Oracle Java installation instructions on 64-bit Ubuntu Linux system:

      • Type / Copy / Paste:

        sudo chmod a + x jre-7u45-linux-x64.tar.gz

      Install Oracle Java JRE on Ubuntu Linux Step 7
      Install Oracle Java JRE on Ubuntu Linux Step 7

      Step 7. Unzip the Java binary files in the / usr / local / java directory

      • 32-bit Oracle Java installation instructions on 32-bit Ubuntu Linux system: '

        • Type / Copy / Paste:

          sudo tar xvzf jre-7u45-linux-i586.tar.gz

      • 64-bit Oracle Java installation instructions on 64-bit Ubuntu Linux system:

        • Type / Copy / Paste:

          sudo tar xvzf jre-7u45-linux-x64.tar.gz

        Install Oracle Java JRE on Ubuntu Linux Step 8
        Install Oracle Java JRE on Ubuntu Linux Step 8

        Step 8. Check the directories

        At this point, you should have an unzipped binary file directory in / usr / local / java for the Java JDK / JRE indicated as:

        • Type / Copy / Paste:

          ls -a

        • jre1.7.0_45
        Install Oracle Java JRE on Ubuntu Linux Step 9
        Install Oracle Java JRE on Ubuntu Linux Step 9

        Step 9. Edit the PATH variable file / etc / profile and add the following variables to the system PATH

        Use nano, gedit or other text programs. As an administrator, open / etc / profile.

        • Type / Copy / Paste:

          sudo gedit / etc / profile

        • or
        • Type / Copy / Paste:

          sudo nano / etc / profile

        Install Oracle Java JRE on Ubuntu Linux Step 10
        Install Oracle Java JRE on Ubuntu Linux Step 10

        Step 10. Scroll down with the arrows and enter what is indicated in the following lines at the end of the / etc / profile file:

        • Type / Copy / Paste:

          JAVA_HOME = / usr / local / java /jre1.7.0_45

          PATH = $ PATH: $ HOME / bin: $ JAVA_HOME / bin

          export JAVA_HOME

          export PATH

        Install Oracle Java JRE on Ubuntu Linux Step 11
        Install Oracle Java JRE on Ubuntu Linux Step 11

        Step 11. Save the / etc / profile file and exit

        Install Oracle Java JRE on Ubuntu Linux Step 12
        Install Oracle Java JRE on Ubuntu Linux Step 12

        Step 12. Tell the Linux Ubuntu system where Oracle Java JRE is located

        This will tell the system that a new version of Oracle Java is ready to use.

        • Type / Copy / Paste:

          sudo update-alternatives --install "/ usr / bin / java" "java" "/usr/local/java/jre1.7.0_45/bin/java" 1

          This command notifies the system that the Oracle Java JRE is ready to use

        • Type / Copy / Paste:

          sudo update-alternatives --install "/ usr / bin / javaws" "javaws" "/usr/local/java/jre1.7.0_45/bin/javaws" 1

          This command notifies the system that Oracle Java Web is ready to use

        Install Oracle Java JRE on Ubuntu Linux Step 13
        Install Oracle Java JRE on Ubuntu Linux Step 13

        Step 13. Inform the Linux Ubuntu system that Oracle Java JRE must be the default Java

        • Type / Copy / Paste:

          sudo update-alternatives --set java /usr/local/java/jre1.7.0_45/bin/java

          This command will set the Java environment on the system

        • Type / Copy / Paste:

          sudo update-alternatives --set javaws /usr/local/java/jre1.7.0_45/bin/javaws

          This command will set Java Web on the system

        Install Oracle Java JRE on Ubuntu Linux Step 14
        Install Oracle Java JRE on Ubuntu Linux Step 14

        Step 14. Reload the PATH / etc / profile variable with the following command:

        • Type / Copy / Paste:

          / etc / profile

        • The PATH variable / etc / profile will be reloaded after system reboot.
        Install Oracle Java JRE on Ubuntu Linux Step 15
        Install Oracle Java JRE on Ubuntu Linux Step 15

        Step 15. Test to see if Oracle Java was installed correctly

        Run the following command and check the Java version:

        Install Oracle Java JRE on Ubuntu Linux Step 16
        Install Oracle Java JRE on Ubuntu Linux Step 16

        Step 16. A successful 32-bit Oracle Java installation will show:

        • Type / Copy / Paste:

          java -version

          This command will show the current version of java installed on your system

        • You should get the following message:

          • java version "1.7.0_45"

            Java (TM) SE Runtime Environment (build 1.7.0_45-b18)

            Java HotSpot (TM) Server VM (build 24.45-b08, mixed mode)

          Install Oracle Java JRE on Ubuntu Linux Step 17
          Install Oracle Java JRE on Ubuntu Linux Step 17

          Step 17. A successful 32-bit Oracle Java installation will show:

          • Type / Copy / Paste:

            java -version

            This command will show the current version of Java installed on your system

          • You should get the following message:

            • java version "1.7.0_45"

              Java (TM) SE Runtime Environment (build 1.7.0_45-b18)

              Java HotSpot (TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

            Install Oracle Java JRE on Ubuntu Linux Step 18
            Install Oracle Java JRE on Ubuntu Linux Step 18

            Step 18. Congratulations, you have just installed Oracle Java JRE on your Linux system

            Now reboot your Linux Ubuntu system, after which it will be fully configured to Java.

            Optional: How to Enable Oracle Java in Your Internet Browser

            To enable the Java plug-in in your browser you need to create a symbolic link between your browser plug-in and the location of the Java plug-in included in the Oracle Java distribution

            Important note:

            Please enable Oracle Java 7 in your browser with caution due to security issues and vulnerabilities. Essentially, by enabling Oracle Java 7 in your browser you could be encouraging someone's unwanted access to your system, compromising it. For more information on Java security and vulnerabilities visit the following site: Java Test

            Google Chrome

            Instructions for 32-bit Oracle Java

            1. Run the following commands:

              • Type / Copy / Paste:

                sudo mkdir -p / opt / google / chrome / plugins

                This will create a directory called / opt / google / chrome / plugins

              • Type / Copy / Paste:

                cd / opt / google / chrome / plugins

                This will take you to the Google Chrome plug-in directory; make sure you are in this directory before creating the symbolic link

              • Type / Paste / Copy:

                sudo ln -s /usr/local/java/jre1.7.0_40/lib/i386/libnpjp2.so

                This will create a symbolic link from the Java JRE (Java Runtime Environment) plug-in libnpjp2.so to Google Chrome.

            Instructions for 64-bit Oracle Java

            1. Run the following commands:

              • Type / Copy / Paste:

                sudo mkdir -p / opt / google / chrome / plugins

                This will create a directory called / opt / google / chrome / plugins

              • Type / Copy / Paste:

                cd / opt / google / chrome / plugins

                This will take you to the Google Chrome plug-in directory; make sure you are in this directory before creating the symbolic link

              • Type / Copy / Paste:

                sudo ln -s /usr/local/java/jre1.7.0_40/lib/amd64/libnpjp2.so

                This will create a symbolic link from the Java JRE (Java Runtime Environment) plug-in libnpjp2.so to Google Chrome.

            Memorandum

            1. Note:

              Sometimes when you run the above command you may get this message:

              • ln: creating symbolic link `./libnpjp2.so ': File exists
              • To correct this problem remove the previous symbolic link with the command:
              • Type / Copy / Paste:

                cd / opt / google / chrome / plugins

              • Type / Copy / Paste:

                sudo rm -rf libnpjp2.so

              • Make sure you are in the / opt / google / chrome / plugins directory before running the command.
            2. Restart your browser and go to Java Test to test if Java works.

              Mozilla Firefox

              Instructions for 32-bit Oracle Java

              1. Run the following commands:

                • Type / Copy / Paste:

                  cd / usr / lib / mozilla / plugins

                  This will lead to the / usr / lib / mozilla / plugins directory; create this directory if it doesn't already exist

                • Type / Copy / Paste:

                  sudo mkdir -p / usr / lib / mozilla / plugins

                  This will create the / usr / lib / mozilla / plugins directory; make sure you are in this directory before creating the symbolic link

                • Type / Copy / Paste:

                  sudo ln -s /usr/local/java/jre1.7.0_40/lib/i386/libnpjp2.so

                  This will create a symbolic link from the Java JRE (Java Runtime Environment) plug-in libnpjp2.so to Mozilla Firefox.

              Instructions for 64-bit Oracle Java

              1. Run the following commands:

                • Type / Copy / Paste:

                  cd / usr / lib / mozilla / plugins

                  This will lead to the / usr / lib / mozilla / plugins directory; create this directory if it doesn't already exist

                • Type / Copy / Paste:

                  sudo mkdir -p / usr / lib / mozilla / plugins

                  This will create the / usr / lib / mozilla / plugins directory; make sure you are in this directory before creating the symbolic link

                • Type / Copy / Paste:

                  sudo ln -s /usr/local/java/jre1.7.0_40/lib/amd64/libnpjp2.so

                  This will create a symbolic link from the Java JRE (Java Runtime Environment) plug-in libnpjp2.so to Mozilla Firefox.

              Memorandum

              1. Note:

                Sometimes, when you run the above command, you may get this message:

                • ln: creating symbolic link `./libnpjp2.so ': File exists
                • To correct this problem remove the previous symbolic link with the command:
                • Type / Copy / Paste:

                  cd / usr / lib / mozilla / plugins

                • Type / Copy / Paste:

                  sudo rm -rf libnpjp2.so

                • Make sure you are in the / usr / lib / mozilla / plugins directory before running the command.
              2. Restart your browser and go to Java Test to test if Java works.

Recommended: