How to change JDK location in Android Studio?

When I open my project in Android Studio I see default JDK https://i.stack.imgur.com/XP8HN.png

I went to settings and tried to change jdk but it didn't save. The previos path is still showed in Android Studio enter image description here

I saw other threads, one of my path doesn't contains s whitespace.

Should I change something in my gradle.kts file?


Solution 1:

You can change File > Project Structure > SDK Location

enter image description here

OR, You can change local.properties files

Sample:

sdk.dir=D\:\\Sdk

Solution 2:

java -version

Would help us to know to the current java version. To switch between the installed java versions, update-java-alternatives would help.

To list all java versions installed in the device

update-java-alternatives --list

To set a java version as default,

sudo update-java-alternatives --set <path_to_installed_java_version>