Install JDK1.8 Manually

Install JDK1.8 Manually

Command to download the package
> 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/8u60-b27/jdk-8u60-linux-x64.tar.gz"

We can check the latest version from here.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Unzip and place the files in working directory

Use alternatives install from chkconfig package
> sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_60/bin/java 2

Configure the Java Version
> sudo alternatives --config java

Check java version
> java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Then we do the alternatives for jar javac command as well.

> sudo alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_60/bin/jar 2

> sudo alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_60/bin/javac 2

> sudo alternatives --set jar /opt/jdk1.8.0_60/bin/jar

> sudo alternatives --set javac /opt/jdk1.8.0_60/bin/javac

> sudo alternatives --config javac

> sudo alternatives --config jar

Configure the Environment
>  vi ~/.bash_profile

JAVA_HOME=/opt/jdk1.8.0_60
export JAVA_HOME

JRE_HOME=/opt/jdk1.8.0_60/jre
export JRE_HOME

PATH=$PATH:$HOME/bin:/opt/maven/bin
PATH=$PATH:/opt/sbt/bin
PATH=$PATH:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin

export PATH

> . ~/.bash_profile

Check version
> java -version
java version "1.8.0_60"

> javac -version
javac 1.8.0_60

References:
http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

你可能感兴趣的:(Install JDK1.8 Manually)