I installed Android Studio in Ubuntu by following two commands:

  1. sudo apt-get ubuntu-make
  2. 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?


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

  1. List Java alternatives:

    update-java-alternatives -l
  2. Find the line with the Java you want.

  3. 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.

  4. 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

Oracle Java is the JDK officially supported by android studio, and you can change your jdk setting using

update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_20/bin/java" 1    
update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_20/bin/javac" 1

Change in command line according to the version downloaded and path.

  • Actually I am sking shoiuld I change from Open JDK to Oracle JDK – thepurpleowl Mar 29 '16 at 18:23
  • update-java-alternatives is the proper way to switch Java over. Your instructions miss out on things like javap and other Java executables as well as the web browser plugin. – Olathe Mar 29 '16 at 18:31

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.