Set JAVA_HOME and ANDROID_HOME properly on macOS Catalina

davitperaze

Davit Peradze

Posted on October 9, 2020

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 🙃

💖 💪 🙅 🚩
davitperaze
Davit Peradze

Posted on October 9, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related