Downloading Latest Java Archive
Java latest archive is available on its official site. We recommend to download latest version of Java from Oracle official website. After completing download also extract archive with given commands.
For 64 Bit:-
# cd /opt/ # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz" # tar xzf jdk-7u79-linux-x64.tar.gz
For 32 Bit:-
# cd /opt/ # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-i586.tar.gz" # tar xzf jdk-7u79-linux-i586.tar.gz
Use archive file as per your system configuration. For this example we are using CentOS 7.0 (64 bit) system.
Install Java with Alternatives
After extracting Java archive file, we just need to set up to use newer version of Java using alternatives. Use the following commands to do it.
# cd /opt/jdk1.7.0_79/
# alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 2
# alternatives --config java
There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- * 1 /opt/jdk1.7.0_60/bin/java + 2 /opt/jdk1.7.0_72/bin/java 3/opt/jdk1.7.0_79/bin/java Enter to keep the current selection[+], or type selection number:3 [Press Enter]
Now you may also required to set up javac and jar commands path using alternatives command.
# alternatives --install/usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 2 # alternatives --install/usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 2 # alternatives --setjar /opt/jdk1.7.0_79/bin/jar # alternatives --setjavac /opt/jdk1.7.0_79/bin/javac
Check Installed Java Version
Use following command to check which version of Java is currently being used by system.
# 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)
No comments:
Post a Comment