Install oracle java in Cent-OS

From Notes_Wiki
Revision as of 15:27, 14 October 2013 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>Java|Java</yambe:breadcrumb> =Install oracle Java in Cent-OS= # Download java-sdk with netbeans from http://www.oracle.com/technetwork/java/javase/downloads...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>Java|Java</yambe:breadcrumb>

Install oracle Java in Cent-OS

  1. Download java-sdk with netbeans from http://www.oracle.com/technetwork/java/javase/downloads/index.html Download .sh file.
  2. Give execute permissions to .sh file using 'chmod +x jdk-7u40-nb-7_3_1-linux-x64.sh'. In this and all future steps replace the version of java and netbeans with the version of java and netbeans downloaded appropriately.
  3. Execute setup using sudo jdk-7u40-nb-7_3_1-linux-x64.sh or similar command based on version downloaded
  4. Choose to install both jdk and netbeans in '/opt/jdk1.7.0_40' and '/opt/netbeans-7.3.1' etc. instead of installing in '/usr/local'. Again name of folders inside opt may differ based on java and netbeans versions.
  5. Check for currently installed java versions using:
    sudo /usr/sbin/alternatives --display java
  6. Configure installed version as preffered alternative using:
    sudo /usr/sbin/alternatives --install /usr/bin/java java /opt/jdk1.7.0_40/bin/java 170040
    where number 170040 must be greater than priority of existing installed versions of java. Same as before the path of jdk should be appropriately changed in above command based on installed version.
  7. Verify that the new installed version is preferred using:
    sudo /usr/sbin/alternatives --display java
  8. Edit ~/.bash_profile as follows:
    1. Append '/opt/jdk1.7.0_40/bin:/opt/jdk1.7.0_40/jre/bin' to existing PATH value. If alternatives method for making java preferred is not desirable / present then prepend the value to PATH to make installed java preferred.
    2. Add following lines near the end of file:
      JAVA_HOME=/opt/jdk1.7.0_40
      JRE_HOME=/opt/jdk1.7.0_40/jre
      export JAVA_HOME
      export JRE_HOME
  9. Test by starting new terminal and using:
    . ~/.bash_profile
    set | grep JAVA
    set | grep JRE
    echo $PATH


<yambe:breadcrumb>Java|Java</yambe:breadcrumb>