DEV Community

Cover image for Set JAVA_HOME and ANDROID_HOME properly on macOS Catalina
Davit Peradze
Davit Peradze

Posted on • Updated on

Set JAVA_HOME and ANDROID_HOME properly on macOS Catalina

Hello DEV community! This is my first post here πŸš€

A couple of days ago, I've switched from Windows to macOS. It was a little bit painful.

I was trying to set up an environment for mobile test automation. From the beginning, everything was going OK. But the environment variables were reset automatically.

I've searched and tried to fix the issue. And finally, I did it.

Couse macOS Catalina uses ~/.zprofile instead of ~/.bash_profile, using an old standard was misleading.

So, I've used ~/.zprofile to set the environment and the result was a reliever.

So, the content of ~/.zprofile file for JAVA_HOME and ANDROID_HOME is shown below:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

export ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Enter fullscreen mode Exit fullscreen mode

jdk1.8.0_271.jdk would be different. Check the directory before typing.

After saving the file, you must run source ~/.zprofile to apply changes to the environment.

Think, it'll be helpful for someone πŸ™ƒ

Top comments (1)

Collapse
 
pablotoledo81 profile image
pablotoledo81

Really useful, worked for me - thank you!