Although Ubuntu comes in with a preinstalled version of Oracle Java JDK, Android Studio requires a newer version to function properly on Linux. We’ve included a full guide on how to update Oracle Java JDk below:
1. Open your application drawer, then search & open Terminal.
2. Insert the following commands into your Terminal and hit Enter:
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
3. The following message will appear. Hit Enter to begin the process.
4. After a while, the installation will need additional space to complete the update. Type Y and hit Enter to confirm.
5. Accept the oracle Binary Code license terms by selecting Yes.
6. Wait until the updating process is complete.
7. Use javac -version to see the latest Java JDK version and java -version to see the version of Java installed on your system.