March 19, 2020
Estimated Post Reading Time ~

How to Setup Environment Variables on MAC Machine

For Setting up Environment Variables on MAC Machine firstly we need to have a bash profile, We will see in this post how to create a bash profile and setting up the environment variables for Java and Maven. 

Creating a. Bash_profile on your mac

A typical install of os x won't create a .bash_profile for you. When you want to run functions from your command line, this is a must-have.
         1.      Startup terminal
         2.      Type "cd ~/" to go to your home folder
         3.      Type "touch .bash_profile" to create your new file.
         4.      Edit .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in Text Editor.
         5.      Type ". .bash_profile" to reload .bash_profile and update any functions you add.

Cd ~/
Touch .bash_profile
Open -e .bash_profile (here enter all the paths)
. .bash_profile

Export java_home=$(/usr/libexec/java_home)
Export m2_home=/users/testern/desktop/softwares/apache-maven-3.5.0
Export path=$path:$java_home/bin:${m2_home}/bin

Note: Here I have my maven zip (apache-maven-3.5.0) extracted folder is on my Desktop, here is the path for my maven files. It would be different for you if you are placing it in different locations you need to update the path.

 "/users/tester/desktop/softwares/apache-maven-3.5.0"
  
Testing: 
After installing and setting up Java/Maven we need to test it whether it is installed correctly or not for that you need to run below commands.

For Java: 
Open your terminal on your mac and type "javac", 
To find out what version of java is installed type "java -version" then hit enter.

For Maven: 
Open your terminal on your mac and type "mvn", 
To find out what version of java is installed type "mvn -version" then hit enter.



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.