How to specify the JDK version in android studio?

You can use cmd + ; for Mac or Ctrl + Alt + Shift + S for Windows/Linux to pull up the Project Structure dialog. In there, you can set the JDK location as well as the Android SDK location.

Project Structure Dialog

To get your JDK location, run /usr/libexec/java_home -v 11 in terminal. Send 1.7 for Java 7, 1.8 for Java 8, or 11 for Java 11.


Android Studio Arctic Fox (2020.3.1)

In Android Studio Arctic Fox (2020.3.1 Patch 4), the JDK Location setting is moved to:

File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK

Up to Android Studio 4.2

You can follow the answer from Ben Kane, the JDK Location setting is located in:

File > Project Structure > SDK Location