title: Ubuntu: change the path from OpenJDK 6 to Oracle JDK 7
body: <p>After downloading the latest .tar file I ran <code>tar zxvf jdk-7u45-linux-x64.tar.gz</code> to extract java files. </p>
  
  <p>Set the path in <code>.bashrc</code> file (<code>vi ~/.bashrc</code>) as below; </p>
  
  <pre><code>export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45/bin/java
  export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_45/bin
  export JDK_HOME=/usr/lib/jvm/jdk1.7.0_45    
  export JRE_HOME=/usr/lib/jvm/jre1.7.0_45
  </code></pre>
  
  <p>Now, running command <code>java -version</code> or which java, java PATH still pointing to the older java version (<code>java version "1.6.0_27"</code>).</p>
  
  <p>I know default ubuntu takes OpenJDK path. I have to change the path as latest version as my system environment variable set in <code>.bashrc</code> file.</p>
  
  <p>Also, <code>sudo update-alternatives --config java</code></p>
  
  <pre><code>Selection    Path                                      Priority   Status
  ------------------------------------------------------------
    0            /usr/lib/jvm/java-7-oracle/jre/bin/java    1062      auto mode
    1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
    2            /usr/lib/jvm/java-7-oracle/jre/bin/java    1062      manual mode
  * 3            /usr/lib/jvm/jdk1.7.0_45/bin/java          1         manual mode
  Press enter to keep the current choice[*], or type selection number: 3
  </code></pre>