JAVA_HOME isn't being set/ saved to the path variable after the terminal instance is being closed
<p>I have been using Java 1.7 until recently for my code base, and recently we have upgraded to java 8. 
When am trying to set the JAVA_HOME variable in the .bash_profile / .bashrc file as :</p>

<pre><code>export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
</code></pre>

<p>and save it and use the source .bash_profile, the java -version points to :</p>

<pre><code>Nitin-Vegis-MacBook-Pro:/ nitinsuryavegi$ java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
</code></pre>

<p>but when i quit the terminal/ close the session and recheck the java - version it points back to the old version as this :</p>

<pre><code>Nitin-Vegis-MacBook-Pro:/ nitinsuryavegi$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
</code></pre>

<p>Could you help me set the JAVA_HOME path permanently so i need not run the source .bash_profile every time i log into my terminal to keep changing the java -version from 1.7 to 1.8.</p>

<p>Also could someone help me understand :</p>

<ol>
<li>The difference between .bash_profile and .bashrc file.</li>
<li>When i check the Java Runtime Version in my System Preferences it's been pointed to 1.8</li>
</ol>

<p><a href="https://i.stack.imgur.com/TjyyZ.png" rel="nofollow noreferrer">Click here for reference</a>, but when i check the java -version in the terminal it shown as :</p>

<pre><code>java version "1.7.0_79"
</code></pre>

<ol start="3">
<li>What is difference between <strong><em>$JAVA_HOME</em></strong> and <strong><em>whereis java</em></strong> command ?</li>
</ol>