Setting environment variables on macOS
Everytime I get a new computer, I install Java on it, and then Android Studio. And everytime I have
to remember how to set ANDROID_HOME
and JAVA_HOME
. And I forget, and do the same Google searches
π. So Iβve decided to write it down this time.
In your home directory, create this .profile
file.
# more info https://goo.gl/YHmHGp
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/nazmul/Library/Android/sdk
export PATH="/Users/nazmul/scripts:$PATH"
launchctl setenv ANDROID_HOME $ANDROID_HOME
launchctl setenv JAVA_HOME $JAVA_HOME
Now replace all the /Users/nazmul
folders with your username!
Then restart Terminal, and you are good to go.
This will work for launching Android Studio from Finder as well. Since if you donβt do the
launchctl
stuff, your environment variables will be set when youβre in Terminal, but not when you
launch something from Finder.
π Watch Rust π¦ live coding videos on our YouTube Channel.
π¦ Install our useful Rust command line apps usingcargo install r3bl-cmdr
(they are from the r3bl-open-core project):
- π±
giti
: run interactive git commands with confidence in your terminal- π¦
edi
: edit Markdown with style in your terminalgiti in action
edi in action