Install oracle java in Cent-OS
From Notes_Wiki
<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/index.html Download .sh file.
- 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.
- Execute setup using sudo jdk-7u40-nb-7_3_1-linux-x64.sh or similar command based on version downloaded
- 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.
- Check for currently installed java versions using:
- sudo /usr/sbin/alternatives --display java
- 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.
- Verify that the new installed version is preferred using:
- sudo /usr/sbin/alternatives --display java
- Edit ~/.bash_profile as follows:
- 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.
- 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
- Test by starting new terminal and using:
- . ~/.bash_profile
- set | grep JAVA
- set | grep JRE
- echo $PATH
<yambe:breadcrumb>Java|Java</yambe:breadcrumb>