I am trying to install Java JRE 8 on my Linux machine (Ubuntu 14.04 (Trusty Tahr)). I've done two things:

The first was follow Java's help page. I downloaded the tarball and installed it using the tar zxvf jre-8u73-linux-x64.tar.gz command. However, when I run:

java -version

I get: bash: /usr/bin/java: No such file or directory

There are no configuration files, and the binary files in /bin/ are endless... I am not sure which I am supposed to execute. I tried to execute the java file, but that did nothing.

So, I tried to just apt-get it. These are the commands I ran:

add-apt-repository ppa:openjdk-r/ppa
apt-get update
apt-get install openjdk-8-jre

However, again, when I run java -version, it displays the same thing.

So I said screw it, let me just mkdir /usr/bin/java and try it again. I autoremoved the package, and reinstalled it. Now I just get bash: /usr/bin/java: Is a directory when I run java -version.

How can I fix this?

  • With the command mkdir /usr/bin/java you create a directory not an executable, so that's why you get bash: /usr/bin/java: Is a directory. Try to remove /usr/bin/java, reinstall the package via ppa and apt and write the output of the command ls -l /usr/bin/*java* please. – ceccoemi Aug 16 '17 at 16:36
  • When I run that command, I get ls: cannot access /usr/bin/*java*: No such file or directory. Interestingly enough, when I run java -version, I get a couple of java packages, but not openjdk-8-jre – John Lexus Aug 16 '17 at 16:46
  • I follow this guide since times a go, it's very good: digitalocean.com/community/tutorials/…. Type "update-aternatives --display java" and you will see which versions of java are installed. So you can uninstall then by command update-alternatives --remove ... – Redbob Aug 16 '17 at 17:04

The other responses for some weird reason did not work for me. So, to install java 1.8 (from Oracle), I alternatively ran this:

1: Add Oracle’s PPA (Personal Package Archive):

sudo add-apt-repository ppa:webupd8team/java

2: Then update your package repository

sudo apt-get update

3: Install Oracle JDK 8:

sudo apt-get install oracle-java8-installer

That got it working for me. Now, when I run java -version, I get:

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode

For more details, see this post on Medium.com.


I don't know why you're not able to install openjdk from the ppa ppa:openjdk-r/ppa, maybe it has some problems. But if you want to install the Oracle Java, after you have extracted the folder with tar zxvf jre-8u73-linux-x64.tar.gz, you have to make a symbolic link to the executable, try with sudo ln -sv /path-to-extracted-folder/bin/java /usr/local/bin/java.


Installing the Default JRE/JDK

Firstly you update the package index

sudo apt update

Next install Java Runtime Environment(JRE) type by

sudo apt-get install default-jre

And install Java Development Kit (JDk) type by

sudo apt-get install default-jdk

Installing the Oracle JDK

Add Oracle's PPA, then update your package.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

What version you needed typing in terminal

sudo apt-get install oracle-java6/7/8/9-installer

After installed Java you Managing your Java version

sudo update-alternatives --config java

Setting the JAVA_HOME Environment Variable

sudo update-alternatives --config java

Copy the path from your preferred installation and then open /etc/environment using nano or your favorite text editor.

sudo nano /etc/environment

Add a line like this to the file (with the correct path):


Save and exit the file, and reload it.

source /etc/environment

You can now test whether the environment variable has been set by executing the following command:


And type

javac --version
java --version 

These commands display what version of java (the interpreter that runs Java programs) and javac (the compiler that creates them) you have installed.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.