Set Environment Variable paths for Java, Node and Android SDK— Mac

Tharaka Liyanage
4 min readNov 29, 2021

--

Welcome to Appium blog series…🤗 You are in the right place if you have already installed Java, Android Studio, Node in your Mac and looking on how to set up Environment Variables or Home paths for these softwares.

If you are still not installed Java, Android Studio and Node, you can have a look on my previous blog.

Here, in this blog I am explaining simple steps which you can follow on setting up your Environment variables.

Let’s start guys..😎

Set up Java Home Path

  1. Open your Terminal
  • Use the keyboard shortcut Command + Space
  • Type in “Terminal”.
  • You should see the Terminal under Top Hit at the top of your results
  • Double-click it and Terminal will open.

2. Open your Bash profile

  • Type vim command in your terminal to open Bash Profile
    command : vi ~/.bash_profile

This will open your bash profile and initially you will not see any environment variable paths set for Java, Node and Android SDK.

Note :
To exit from Bash profile tap on esc key → Type : q
To save changes done and exit from Bash profile tap on esc key → Type : wq

3. Set Java Home Path

  • Exit from the bash profile and Type open /usr/libexec in your Terminal
  • Below window will open and you can see where the java located in your machine
  • Now open bash profile again by typing vi ~/.bash_profile command
  • Press i in-order to make bash profile editable
    - i indicates insert
    -
    Once you press i you will see INSERT in left bottom corner of the Bash profile. This means you are in the editable mode.
  • Add Java home path by inserting below line
    export JAVA_HOME=$(/usr/libexec/java_home)
  • Setting up PATH variable by inserting below line
    export PATH=$PATH:/usr/local/bin:
  • Press esc and type : wq to save changes and exit
  • To add these paths permanently , it is mandatory to give source ~/.bash_profile command in your Terminal

Set up Android SDK Path

  • Type open /users/tharakal/library/android in your Terminal

Note : Here I have mentioned my home directory name as “tharakal” . Substitute it with your own home directory name instead.

  • Below window will open and you can see where the Android SDK located in your machine.
  • Now open bash profile again by typing vi ~/.bash_profile command
  • Press i in-order to make bash profile insert mode enable
  • Add Android SDK path by inserting below line
    export ANDROID_HOME=/Users/tharakal/Library/Android/sdk
  • Next, set path for platform-tools, because in there we have executable files which are used at run time.
    export PATH=$PATH:$ANDROID_HOME/platform-tools
  • Then, set path for tools
    export PATH=$PATH:$ANDROID_HOME/tools
  • Set path for Android tools/bin
    export PATH=$PATH:$ANDROID_HOME/tools/bin
  • Finally set path for Android Emulator
    export PATH=$PATH:$ANDROID_HOME/emulator
  • Now you should see your bash profile as below after you adding these five paths successfully.
  • Press esc and type : wq to save changes and exit
  • To add these paths permanently , it is mandatory to give source ~/.bash_profile command in your Terminal

Set up Node Home Path

We do not need to set Node home path explicitly. Because Node executable files are stayed in /usr/local/bin and we have already set this in our early steps.

To make sure this, type open /usr/local/bin in your Terminal and you will see your node executable file is located in here.

As the final step, to make sure that you have successfully set these home paths you can simply type below commands in your Terminal.

echo $JAVA_HOME
echo $ANDROID_HOME
echo $PATH

If you are getting paths for these commands as below, which means you have successfully set up required home paths for Java and Android SDK and Node.

See you in the next blog..✌️

--

--