To compile latest android applications, Android may ask us to make sure we have JDK17 installed on our machine i.e. Ubuntu if we are Linux user.
To Install JDK17 on Ubuntu, first we need to down the deb file from https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html
We can also download using wget command as,
$ wget -c https://download.oracle.com/java/17/archive/jdk-17.0.8_linux-x64_bin.deb
The latest JDK17 deb file available when we installed on our machine was jdk-17.0.8_linux-x64_bin.deb so, we installed this using below command,
$ sudo dpkg -i jdk-17.0.8_linux-x64_bin.deb
once this is successful, close the current terminal and start the new terminal to make sure we have our environment variables updated after latest installation of JDK17.
Now, we can see the JDK17 installed using command,
$ java -version java version "17.0.8" 2023-07-18 LTS Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211) Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)
$ update-java-alternatives --list java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64 java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64 jdk-17-oracle-x64 285278208 /usr/lib/jvm/jdk-17-oracle-x64
As we can see above in “java version” check, we are using JDK 17. If you still have another JDK configured, you can try to change to JDK 17 by following steps from “How to Switch Between Multiple Java Versions On Ubuntu Linux ?”
Remove JDK 17
To remove oracle JDK17 we can use below command,
$ sudo apt remove jdk-17