How do I uninstall Java 11 to be able to install Java 8 for Android Studio?
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.
Solution 1:
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
Solution 2:
/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