Changing JDK from Open JDK to Oracle JDK
Why choose Oracle Java?
Oracle Java is what most Java projects use. They test their products using it. They don't usually test their products on OpenJDK.
This means that bugs get fixed when they show up on Oracle Java. Bugs don't usually get fixed when they show up only on OpenJDK.
If you want a less buggy experience in general, Oracle Java is a better option.
Installing Oracle Java the nice way
Ubuntu's APT package manager makes it easy to install software, uninstall software, and update software. If you want these benefits with Oracle Java, do the following (replace java8
with the version you want; for example, to get Java 9, install oracle-java9-installer
instead):
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java8-installer
To switch between installed JDKs
List Java alternatives:
update-java-alternatives -l
Find the line with the Java you want.
Remember the first part of the line. For example, Oracle Java 8's line might look like this on your system:
java-8-oracle 1082 /usr/lib/jvm/java-8-oracle
The first part of the line there is
java-8-oracle
.Set the first part of the line you want as the Java alternative (replace
java-8-oracle
with the Java you want):sudo update-java-alternatives -s java-8-oracle
Related videos on Youtube
thepurpleowl
Updated on September 18, 2022Comments
-
thepurpleowl over 1 year
I installed Android Studio in Ubuntu by following two commands:
sudo apt-get ubuntu-make
umake android
It installed with OpenJDK bydefault using Ubuntu Developer Tool.
Now I want to change JDK from Open JDK to Oracle JDK. Should I do it? If yes, why? If not, then how do I change the JDK to Oracle?
-
Ashu about 8 yearsPossible duplicate of How to set the JDK for Android Studio?
-
Olathe about 8 years
update-java-alternatives
is the proper way to switch Java over. Your instructions miss out on things likejavap
and other Java executables as well as the web browser plugin. -
thepurpleowl about 8 yearshow to change the jdk from open jdk to oracle jdk in android studio?
-
Olathe about 8 yearsTry this answer: askubuntu.com/a/663557/147763