How to install Java runtime on Linux

Question: I want to run a Java application on my Linux. For that, I need to set up Java Runtime Environment (JRE). How can I install Java Runtime on [insert your Linux distro]?

Java Runtime Environment (JRE) or Java Runtime is a minimal set of Java SDK, which allows one to run Java applications. JRE consists of Java Virtual Machine (JVM), libraries, and other supporting components.

There are two choices for setting up JRE on Linux: use either Oracle JRE or OpenJDK JRE (open source implementation of the Java Platform). Choose either one you prefer.

Install Oracle JRE on Linux

Go to Oracle website, and click on "JRE Download" link.

On the next page, accept Oracle license agreement. Then download a file according to your Linux system:

  • Non-RPM based Linux (e.g., Debian, Ubuntu, Mint): jre-7u45-linux-i586.tar.gz (32-bit) or jre-7u45-linux-x64.tar.gz (64-bit)
  • RPM-based Linux (e.g., Fedora, CentOS, RHEL): jre-7u45-linux-i586.rpm (32-bit) or jre-7u45-linux-x64.rpm (64-bit)

To install Oracle JRE on RPM-based Linux:

$ sudo rpm -ivh jre1.7.0_45-linux-<arch>.rpm

To install Oracle JRE on non RPM-based Linux:

$ sudo mkdir -p /usr/java
$ sudo tar xvfvz jre1.7.0_45-linux-<arch>.tar.gz -C /usr/java

After installation, set the following environment variables in ~/.bashrc


Install OpenJDK Java Runtime on Linux

To install OpenJDK Java Runtime on Debian, Ubuntu or Linux Mint:

$ sudo apt-get install openjdk-7-jre

To install OpenJDK Java Runtime on Fedora, CentOS or RHEL:

$ sudo yum install java-1.7.0-openjdk

After installation, set JAVA_HOME environment variable in ~/.bashrc


If you cannot find /etc/alternative/jre folder, set JAVA_HOME to an alternative path (e.g., /usr/lib/jvm/default-java).

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

4 thoughts on “How to install Java runtime on Linux

  1. After installation, the path /usr/java/jre1.7.0_45 does not exist. Nothing exists below /usr/java/.
    Why on earth does it have to be that complicated?

    • Try running the following command to find out where JRE is installed.

      $ ls -al /etc/alternatives/java

Leave a comment

Your email address will not be published. Required fields are marked *