Close

How to install JRE on Ubuntu 16.04?

[Last Updated: Apr 5, 2017]

Ubuntu Java Linux 

Update apt-get package index:

$ sudo apt-get update

Install the jre:

 $ sudo apt-get install openjdk-8-jre

Check Java version

$ java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

To find the JRE location:

$ whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

Now see what's in /usr/bin/java

$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Apr  2 13:36 /usr/bin/java -> /etc/alternatives/java

As seen, the real location of the symbolic link '/usr/bin/java' is the right side of ->

Now see what's there:

$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Apr  2 13:36 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

so the root location of jre is /usr/lib/jvm/java-8-openjdk-amd64/jre/

Note that we can also use following to find jre location:

$ sudo update-alternatives --config java

Now we are going to set Java home environmental variable with the jre location we just found.

$ sudo nano /etc/environment

In nano editor add new line:

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre"

Save and exit.

To load our new env variable:

$ source /etc/environment

Now check it out:

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre

See Also