Skip to content

Java Development Kit (JDK)

Introduction

Java Development Kit is a prerequisite for the tools used in Android automation, like Android SDK tools and Android studio IDE, so we need to install it first.
The recommended version should match the current LTS version. At the time this documentation was written, JDK 21 is the latest Long-Term Support (LTS) release of the Java SE Platform.

Checking current versions

To check if Java is already installed in your system, open your terminal and type:

shell
java --version

To check if Java compiler is already installed in your system, open your terminal and type:

shell
javac --version

If an error message appears for any of the above commands, or if the displayed versions don't match the LTS current version, then you need to install the latest LTS version of JDK.

Download

Go to the Oracle Java download site and follow these steps:

  • Select the current LTS version.
  • Select the respective operating system, Windows or MAC.
  • Select and download the correct installation binary file. The most common options are:
    • x64 Installer for Windows.
    • ARM64 DMG Installer for Mac.
  • Accept the terms and signin with the Oracle account if requested. Create a new account in case you don't have one.

Installation

Follow the installation wizard instructions and leave all configurations as default.
After the installation, close and re-open the terminal and check the current version again.

Verify java home variable

The JAVA_HOME is an environment variable that some java-based applications depends on it to work properly.
To check if JAVA_HOME is defined, open the terminal and type:

powershell
$env:JAVA_HOME
shell
echo $JAVA_HOME

The correct output for this command should be a text like this:

text
C:\Program Files\Java\jdk-21
text
/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home

Verify that the above output value matches the existing java installation folder on your system.
If the value is missing or invalid, update/create an environment variable named JAVA_HOME. To create/update an environment variable, follow the instructions here.