How to Install Oracle Java JRE on Ubuntu Linux

Download ArticleDownload Article

This How.com.vn teaches you how to install the Java Runtime Environment (JRE) on a computer running Ubuntu Linux. While the most common way to install the JRE is by installing the Java Development Kit (JDK)—which installs the JRE by default—you can also install Java by itself.

Method 1
Method 1 of 2:

Using Terminal

Download Article
  1. How.com.vn English: Step 1 Open Terminal.
    Click the Terminal app icon, which resembles a black box, in the bar on the left side of the screen.
    • You can also press Alt+Ctrl+T to bring up the Terminal window.
  2. How.com.vn English: Step 2 Enter the Java install command.
    Type in sudo apt install jre and press Enter. This command prompts Linux to begin searching for the JRE installation site.
    Advertisement
  3. How.com.vn English: Step 3 Enter your password when prompted.
    Type in the password you use to log into your computer, then press Enter. The installation will commence.
  4. How.com.vn English: Step 4 Allow the JRE files to install.
    This will take a few minutes. When you see the terms of use prompt appear, you may proceed.
  5. How.com.vn English: Step 5 Select <Yes> when prompted.
    Press the left arrow key, then press Enter. Java will resume installing.
  6. How.com.vn English: Step 6 Wait for Java to finish installing.
    Once you see your username appear at the bottom of Terminal, you can continue.
  7. How.com.vn English: Step 7 Check your Java version.
    Type in java -version and press Enter, then wait for the Java version number to appear.
  8. How.com.vn English: Step 8 Remove unnecessary files.
    You can get rid of temporary files installed by Java by doing the following:
    • Type in sudo apt autoremove and press Enter.
    • Type in y and press Enter.
  9. Advertisement
Method 2
Method 2 of 2:

Installing Java Manually

Download Article
  1. How.com.vn English: Step 1 Open the Java download site.
    Go to https://www.java.com/en/download/ in your computer's web browser.
  2. How.com.vn English: Step 2 Click Free Java Download.
    It's a red button in the middle of the page. Doing so opens the Downloads page.
  3. How.com.vn English: Step 3 Click the Linux link.
    This option is near the middle of the page. Clicking it should prompt the Java folder to begin downloading.
    • You may first have to click Save to prompt the download to begin.
  4. Step 4 Open the "Downloads" folder.
    Click the Files app icon—which resembles a grey filing cabinet drawer on the left side of the screen—then double-click the "Downloads" folder.
  5. How.com.vn English: Step 5 Extract the downloaded folder.
    Right-click the "jre-#####-linux" folder, then click Extract Here in the resulting drop-down menu. You should see a new, regular folder with a similar name appear in the "Downloads" folder.
  6. How.com.vn English: Step 6 Move the extracted folder if necessary.
    If you want to install Java in a location other than the "Downloads" folder, do the following:
    • Click once the extracted folder to select it.
    • Press Ctrl+X to cut the folder.
    • Go to the folder you want to use as an installation location and open it.
    • Press Ctrl+V to paste in the extracted Java folder.
  7. How.com.vn English: Step 7 Find the extracted folder's "bin" folder.
    Open the extracted folder, then double-click the folder with the Java version number as its name. This will open the Java folder; you should see a folder entitled "bin" here.
  8. How.com.vn English: Step 8 Find the "bin" folder's path.
    To do so:
    • Right-click the "bin" folder.
    • Click Properties.
    • Expand the "Properties" window by clicking and dragging right its right side until the entire "Location" path is visible.
    • Select the "Location" path by clicking and dragging your mouse across it.
    • Press Ctrl+C to copy the path.
  9. Step 9 Open the ".profile" document.
    The easiest way to do this is through Terminal:
    • Open Terminal.
    • Type in gedit .profile and press Enter.
  10. How.com.vn English: Step 10 Create a new line at the bottom of the document.
    Scroll all the way down to the bottom of the document, then click below the bottom text entry.
  11. Step 11 Enter the Java "Home" path.
    The home path is the line export JAVA_HOME=/path where "/path" refers to the path you copied from the "bin" folder; you can paste in the copied path by pressing Ctrl+V. Your end result should resemble something like the following:[1]
    • export JAVA_HOME=/home/name/java/jre1.8.0_181
  12. How.com.vn English: Step 12 Press ↵ Enter to create a new line.
    This new line should be directly beneath the "export JAVA_HOME=" line.
  13. How.com.vn English: Step 13 Specify the PATH variable.
    Type in PATH="$PATH:$JAVA_HOME/bin" and then press Enter.
  14. How.com.vn English: Step 14 Click Save.
    It's in the top-right corner of the window. Doing so saves your changes to the ".profile" document.
  15. How.com.vn English: Step 15 Restart your computer.
    This will apply your changes, thus installing Java:
    • Click
      How.com.vn English: Android 7 Dropdown
      in the top-right corner of the screen.
    • Click
      How.com.vn English: Windows Power
      in the resulting drop-down menu.
    • Click Restart when prompted.
  16. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Video

      Tips

      • Installing the JDK is an easier way to install all of the components needed to create a Java development environment in Ubuntu.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      Advertisement

      Warnings

      • Depending on your computer's specifications and your version of Ubuntu, you may not get the most recent version of the JRE when installing it. Java will automatically select the highest supported version of the JRE for you.
      Advertisement

      About This Article

      How.com.vn English: Jack Lloyd
      Written by:
      How.com.vn Technology Writer
      This article was co-authored by How.com.vn staff writer, Jack Lloyd. Jack Lloyd is a Technology Writer and Editor for How.com.vn. He has over two years of experience writing and editing technology-related articles. He is technology enthusiast and an English teacher. This article has been viewed 668,834 times.
      How helpful is this?
      Co-authors: 17
      Updated: June 7, 2023
      Views: 668,834
      Categories: Ubuntu
      Thanks to all authors for creating a page that has been read 668,834 times.

      Reader Success Stories

      • How.com.vn English: Anonymous

        Anonymous

        May 17, 2016

        "This is the best step-by-step tutorial I have ever seen, and it saved my laptop from ultimate..." more
      Share your story

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement