Table of Contents
Setting JAVA_HOME for Android Development
Step-by-Step Guide
To set the JAVA_HOME environment variable for Android development, follow these steps based on your operating system:
Windows
- Open the Start Menu, search for ‘
Environment Variables‘, and select ‘Edit the system environment variables‘. - In the System Properties window, click the ‘
Environment Variables‘ button. - Under ‘
System variables‘, click ‘New‘ and enter the following:Variable name:JAVA_HOMEVariable value:Enter the path to your JDK installation directory, e.g.,C:\Program Files\Java\jdk-14.0.1.
- Click ‘
OK‘ to close all dialogs.
macOS/Linux
- Open a Terminal window.
- Edit your
.bash_profile,.bashrc, or.zshrcfile using your preferred text editor, e.g.,nano ~/.bash_profile. - Add the line:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home - Save and close the file.
- Run
source ~/.bash_profile(or the respective file) to apply the changes.
Verifying the Setup
After configuring JAVA_HOME, verify the setup by opening a new Terminal or Command Prompt session and typing:
Play free games on Playgama.com
echo %JAVA_HOME%(Windows)echo $JAVA_HOME(macOS/Linux)
Ensure it outputs the correct path to your JDK installation.
Integration with Android Studio
Ensure that Android Studio is correctly pointing to the JAVA_HOME path. In Android Studio, go to File > Project Structure > JDK Location and verify that it corresponds to JAVA_HOME.