How to Install Oracle Java JRE on Linux Ubuntu (with Pictures)

Table of contents:

How to Install Oracle Java JRE on Linux Ubuntu (with Pictures)
How to Install Oracle Java JRE on Linux Ubuntu (with Pictures)

Video: How to Install Oracle Java JRE on Linux Ubuntu (with Pictures)

Video: How to Install Oracle Java JRE on Linux Ubuntu (with Pictures)
Video: How to Disable Image Comments in WordPress (to stop spam) 2024, November
Anonim

This article will cover installing the 32-bit and 64-bit Oracle Java 7 JRE (current version number is 1.8.0_73) on 32-bit and 64-bit Ubuntu operating systems. This guide also applies to Debian and Linux Mint. This article is addressed only if you want to install Oracle Java JRE on a Debian based Linux system, for example Debian, Ubuntu and Linux Mint. Using this method, you only can run and execute Java programs and cannot do development and programming in Java. This article was created due to many requests from other users who want to know how to only install the Oracle Java JRE on owned Ubuntu system. I've also included a section on how to enable the Oracle Java JRE in a web browser and use this method. This guide is applicable to Debian, Ubuntu, and Linux Mint.

Step

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

Step 1. Check to see if the Ubuntu Linux operating system is 32-bit or 64-bit architecture, open a terminal and run the command below

  • Type/Copy/Paste:

    files /sbin/init

    Pay attention to the bit version of your Ubuntu Linux system architecture, whether 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 Java is installed on your system

To do this, you need to run the Java version of the command from the terminal.

  • Open a terminal and enter the following command:

    • Type/Copy/Paste:

      java -version

  • If you have OpenJDK installed on your system, it should look like this:

    • 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)

  • If OpenJDK is installed on your system, you have installed the wrong vendor version of Java for this method.
Install Oracle Java JRE on Ubuntu Linux Step 3
Install Oracle Java JRE on Ubuntu Linux Step 3

Step 3. Remove OpenJDK/JRE from the system and create a directory to hold the Oracle Java JRE binary

This will prevent conflicts and confusion between different vendor versions of Java. For example, if your system has OpenJDK/JRE, remove it by typing the following command in the command line:

  • Type/Copy/Paste:

    sudo apt-get purge openjdk-\*

    This command will remove OpenJDK/JRE from your system completely

  • Type/Copy/Paste:

    sudo mkdir -p /usr/local/java

    This command will create a directory to hold 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 the Oracle Java JRE for Linux

Make sure you choose a compressed binary that Correct for your 32-bit or 64-bit system architecture (those ending in tar.gz).

  • For example, if you are using the 32-bit Ubuntu Linux operating system, download the 32-bit Oracle Java binary.
  • For example, if you are using the 64-bit Ubuntu Linux operating system, download the 64-bit Oracle Java binary.
  • Download Oracle Java JDK/JRE Documentation (optional).

    Select jdk-7u40-apidocs.zip

  • Important information:

    64-bit Oracle Java binary does not work on 32-bit Ubuntu Linux operating system. You will get a number of error messages if you try to install Oracle Java 64-bit on Linux Ubuntu 32-bit.

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

Step 5. Copy the Oracle Java binary to the /usr/local/java directory

In most cases the Oracle Java binary is downloaded to: /home/"your_user_name"/Downloads.

  • Guide to installing Oracle Java 32-bit on Linux Ubuntu 32-bit:

    • Type/Copy/Paste:

      cd /home/"your_user_name"/Downloads

    • Type/Copy/Paste:

      sudo cp -r jre-8u73-linux-i586.tar.gz /usr/local/java

    • Type/Copy/Paste:

      cd /usr/local/java

  • Oracle Java 64-bit installation guide on Linux Ubuntu 64-bit:

    • Type/Copy/Paste:

      cd /home/"your_user_name"/Downloads

    • Type/Copy/Paste:

      sudo cp -r jre-8u73-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 the following command on the downloaded Oracle Java tar.gz file

Make sure you do it as root so that it can be executed by all users on the system. To open a root terminal, type sudo -s and you will be asked to enter a password.

  • Guide to installing Oracle Java 32-bit on Linux Ubuntu 32-bit:

    • Type/Copy/Paste:

      sudo chmod a+x jre-8u73-linux-i586.tar.gz

  • Oracle Java 64-bit installation guide on Linux Ubuntu 64-bit:

    • Type/Copy/Paste:

      sudo chmod a+x jre-8u73-linux-x64.tar.gz

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

Step 7. Open the compressed Java binary, in the directory /usr/local/java

  • Guide to installing Oracle Java 32-bit on Linux Ubuntu 32-bit:

    • Type/Copy/Paste:

      sudo tar xvzf jre-8u73-linux-i586.tar.gz

  • Oracle Java 64-bit installation guide on Linux Ubuntu 64-bit:

    • Type/Copy/Paste:

      sudo tar xvzf jre-8u73-linux-x64.tar.gz

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

Step 8. Double check your directory

At this point, the uncompressed binary is in the /usr/local/java directory for the Java JDK/JRE which is listed as:

  • Type/Copy/Paste:

    ls -a

  • jre1.8.0_73
Install Oracle Java JRE on Ubuntu Linux Step 9
Install Oracle Java JRE on Ubuntu Linux Step 9

Step 9. Edit the system path file /etc/profile and add the following system variables in your system path

Use nano, gedit, or another text editor, as root, go to /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 to the end of the file using the arrow keys and add the following line at the end of the /etc/profile file:

  • Type/Copy/Paste:

    JAVA_HOME=/usr/local/java/jre1.8.0_73

    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 your Oracle Java JRE where your Linux Ubuntu system is

This way, the system knows that the new Oracle Java version can be used.

  • Type/Copy/Paste:

    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.8.0_73/bin/java" 1

    This command notifies the system that the Oracle Java JRE is up and running

  • Type/Copy/Paste:

    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.8.0_73/bin/javaws" 1

    This command notifies the system that Oracle Java Web start can be used

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

Step 13. Tell your Linux Ubuntu system that the Oracle Java JRE should be the default Java

  • Type/Copy/Paste:

    sudo update-alternatives --set java /usr/local/java/jre1.8.0_73/bin/java

    This command will set up the Java runtime environment for your system

  • Type/Copy/Paste:

    sudo update-alternatives --set javaws /usr/local/java/jre1.8.0_73/bin/javaws

    This command will set up Web start Java for your system

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

Step 14. Reload your system-wide PATH /etc/profile by typing the following command:

  • Type/Copy/Paste:

    . /etc/profile

  • Note that the system-wide PATH file /etc/profile will reload after your Linux Ubuntu system is rebooted.
Install Oracle Java JRE on Ubuntu Linux Step 15
Install Oracle Java JRE on Ubuntu Linux Step 15

Step 15. Test to test if Oracle Java is properly installed on your system

Run the following command and note 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-it Oracle Java installation will display:

  • Type/Copy/Paste:

    java -version

    This command displays the version of Java running on your system

  • You should receive a message that says:

    • java version "1.8.0_05"

      Java(TM) SE Runtime Environment (build 1.8.0_05-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 64-bit Oracle Java installation will display:

  • Type/Copy/Paste:

    java -version

    This command displays the version of Java running on your system

  • You should receive a message that says:

    • java version "1.8.0_73"

      Java(TM) SE Runtime Environment (build 1.8.0_05-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 installed the Oracle Java JRE on your Linux system

Now reboot your Ubuntu Linux system. After that, your system will be fully configured to run Java programs.

Optional: How to Enable Oracle Java in Web Browser

To enable Java plug-ins in a web browser, you must create a symbolic link from the web browser plug-in directory to the location of the Java plug-in included in your Oracle Java distribution

Vital Records:

You should be very careful when activating Oracle Java 8 in a web browser as there are many errors and security exploits. In essence, if you enable Oracle Java 8 in a web browser, your system is vulnerable to attacks by bad guys. For more in-depth information on Java security, visit this website: Java Tester

Google Chrome

Oracle Java 32-bit Guide:

  1. Enter the following command.

    • Type/Copy/Paste:

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

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

    • Type/Copy/Paste:

      cd /opt/google/chrome/plugins

      This will turn you into the Google Chrome add-ons directory. Make sure you are in this directory when creating the symbolic link

    • Type/Copy/Paste:

      sudo ln -s /usr/local/java/jre1.8.0_73/lib/i386/libnpjp2.so

      A symbolic link will be created from the Java JRE (Java Runtime Environment) add-on libnpjp2.so for your Google Chrome.

Oracle Java 64-bit Guide:

  1. Enter the following command.

    • Type/Copy/Paste:

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

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

    • Type/Copy/Paste:

      cd /opt/google/chrome/plugins

      This will turn you into the Google Chrome add-ons directory. Make sure you are in the directory before creating a symbolic link

    • Type/Copy/Paste:

      sudo ln -s /usr/local/java/jre1.8.0_05/lib/amd64/libnpjp2.so

      A symbolic link will be created from the Java JRE (Java Runtime Environment) add-on libnpjp2.so to your Google Chrome.

Reminder:

  1. Notes:

    Sometimes when you enter the above command, the following message will appear:

    • ln: creating symbolic link `./libnpjp2.so': File exists
    • To fix this issue, simply remove the previous symbolic link using the following 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 entering the command
  2. Restart the web browser and visit the Java Tester to test if Java works in the web browser.

    Mozilla Firefox

    Oracle Java 32-bit Guide:

    1. Enter the following command.

      • Type/Copy/Paste:

        cd /usr/lib/mozilla/plugins

        This command will change you into 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 command will create a directory /usr/lib/mozilla/plugins. Make sure you are in this directory before creating a symbolic link

      • Type/Copy/Paste:

        sudo ln -s /usr/local/java/jre1.8.0_73/lib/i386/libnpjp2.so

        Your symbolic link will be created from the Java JRE (Java Runtime Environment) add-on libnpjp2.so to your Mozilla Firefox.

    Oracle Java 64-bit Guide:

    1. Enter the following command.

      • Type/Copy/Paste:

        cd /usr/lib/mozilla/plugins

        This will change you 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 command will create a directory /usr/lib/mozilla/plugins. Make sure you are inside this directory before creating a symbolic link

      • Type/Copy/Paste:

        sudo ln -s /usr/local/java/jre1.8.0_73/lib/amd64/libnpjp2.so

        A symbolic link will be created from the Java JRE (Java Runtime Environment) add-on libnpjp2.so to your Mozilla Firefox.

    Reminder:

    1. Notes:

      Sometimes when the command is entered a message will appear that says:

      • ln: creating symbolic link `./libnpjp2.so': File exists
      • To fix it, just remove the previous symbolic link using the following 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 entering the command.
    2. Restart your web browser and visit the Java Tester to test if Java is working properly in the browser.

Recommended: