I tried to install Android Studio but it gave me several problems. Among them is that they told me that it need Java 8 while on my PC Java 11 is installed.
When I run java -version, the result is the following:

java version "11.0.2" 2018-10-16 LTS Java (TM) SE Runtime Environment
18.9 (build 11.0.2 + 7-LTS) Java HotSpot (TM) 64-Bit Server VM 18.9 (build 11.0.2 + 7-LTS, mixed mode)

I see that java is in /usr/bin, in fact there are several java folder/files:

java, javac, javadoc, javafxpackager, javah, javap, javapackager, javaws

How should I remove java in order to install Java 8 and be able to install Android Studio correctly?

Output of ls -l /usr/bin/java:

lrwxrwxrwx 1 root root 22 feb 5 18:56 /usr/bin/java -> /etc/alternatives/java

Output of ls -l /etc/alternatives/java:

lrwxrwxrwx 1 root root 36 feb 16 23:33 /etc/alternatives/java -> /usr/lib/jvm/java-11-oracle/bin/java

I have tried several commands, but the problem is that I do not know exactly how to install it. On the other hand, when I search for Java in "UBUNTU SOFTWARE", Java does not appear.


No need to uninstall your other java version(s) that's already installed on your machine. Whenever required, you can conveniently use the utility 'update-alternatives' to choose the Java runtime that you wish to activate. It will automagically update the required symbolic links.

You just need to run the below command, and select the version of your choice. That's all!

sudo update-alternatives --config java
  • 2
    This only lets you choose from Java versions you previously installed. For example my machine lets me choose between Java 8 Auto and Java 8 Manual. None of the other Java versions appear on the list. Apr 22 '19 at 7:01
  • 1
    Works like a charm. Thank you! Feb 2 at 9:35

/usr/bin/java is a symbolic link to /etc/alternatives/java which is in turn is a symbolic link to /usr/lib/jvm/java-11-oracle/bin/java. From this, it seems that you've downloaded and configured Oracle's Java 11. Moreover JDK doesn't appear as an standalone app in Ubuntu Software.

To get rid of that Java and install Java 8 (OpenJDK):

  • Remove the Oracle's Java folder:

    sudo rm -r /usr/lib/jvm/java-11-oracle
  • Install OpenJDK 8 from APT:

    sudo apt install openjdk-8-jdk openjdk-8-jre
  • Confirm Java version using:

    java -version

The program might require a specific version of java to run. You probably have to download openjdk 8 from the java website or by using the command-line, the link with provide instructions on how to do so. https://openjdk.java.net/install/ deleting the previous version of java shouldn't be necessary

  • 1
    my apologies if this doesn't work Feb 20 '19 at 17:23
  • Thanks, do not help me. Besides should read how to ask a question?and so give some explanation. Just put a link, if that link is broken, the answer does not help. Thank you Feb 20 '19 at 17:50
  • the link works perfectly fine Feb 21 '19 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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