title: Permanently Setting JAVA_HOME environment variable on mac
body: <p>Executing below two commands on mac Terminal which set environment variable, which is vanished on close of Terminal, any help would be appreciated  </p>
  
  <pre><code>Step 1:- echo "export JAVA_HOME=`/usr/libexec/java_home`" &gt;&gt; ~/.profile 
  Step 2:- . ~/.profile
  </code></pre>
  
  <p>Initial Terminal output </p>
  
  <pre><code>karthiks-MacBook-Air:~ karthicklove$ echo "export JAVA_HOME=`/usr/libexec/java_home`" &gt;&gt; ~/.profile
  
  karthiks-MacBook-Air:~ karthicklove$ . ~/.profile
  
  karthiks-MacBook-Air:~ karthicklove$ echo $JAVA_HOME
  /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
  
  Terminal output after closing and reopen again
  
  karthiks-MacBook-Air:~ karthicklove$ echo $JAVA_HOME
  
  karthiks-MacBook-Air:~ karthicklove$ 
  </code></pre>