from:http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/
After a long wait, finally the Java SE development Kit 8 is available to download. JDK 8 have been released on mar,18 for general availability with the many featured enhancements. You can find all the enhancements on JDK 8 here.
This article is to Install the JAVA 8 (JDK 8u66) or update on your system. Read instruction carefully for downloading Java from Linux command line. To Install the Java 8 in Ubuntu and LinuxMint read this article.
Downloading Latest Java Archive
Download Latest Java SE Development Kit 8 release from it official Download page or use following commands to Download fr Om Shell.
For 64Bit
# 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/8u111-b14/ jdk-8u111-linux-x64.tar.gz "# tar Xzf jdk-8u111-linux-x64.tar.gz
For 32Bit
# 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/8u111-b14/ jdk-8u111-linux-i586.tar.gz "# tar Xzf jdk-8u111-linux-i586.tar.gz
Note: If Above wget command does not work for your watch this example video to download Java source archive using terminal.
Install Java with alternatives
After extracting archive file with Alternatives command to install it. Alternatives command is available in the chkconfig package.
# cd/opt/jdk1.8.0_111/# Alternatives--install/usr/bin/java java/opt/jdk1.8.0_111/bin/java Alternatives--config ja Vathere is 3 programs which provide ' Java '. Selection Command-----------------------------------------------* 1 /opt/jdk1.7.0_71/bin/java + 2 /opt/jdk1.8.0_45/bin/java 3 /opt/jdk1.8.0_91/bin/java 4 4
At the this point JAVA 8 have been successfully installed on your system. We also recommend to setup Javac and JAR commands path using alternatives
# Alternatives--install/usr/bin/jar Jar/opt/jdk1.8.0_111/bin/jar Alternatives--install/usr/bin/javac javac/opt/j Dk1.8.0_111/bin/javac Alternatives--set jar/opt/jdk1.8.0_111/bin/jar# Alternatives--set javac/opt/jdk1.8.0_111/ Bin/javac
Check installed Java Version
Check the installed Java version on your system using following command.
[Email protected] ~# Java-versionjava version "1.8.0_111" Java (TM) SE Runtime Environment (build 1.8.0_111-b14) Java HOTSPO T (TM) 64-bit Server VM (build 25.111-b14, Mixed mode)
Configuring Environment Variables
Most of the Java based application ' s uses environment variables to work. Set the Java environment variables using following commands
# Export java_home=/opt/jdk1.8.0_111
# Export JRE_HOME=/OPT/JDK1.8.0_111/JRE
# Export path= $PATH:/opt/jdk1.8.0_111/bin:/opt/jdk1.8.0_111/jre/bin
Also put all above environment variables in /etc/environment file for auto loading on system boot.
Turn: CentOS installation Jdk8