1
, source package preparation:
First download the jdk-8u66-linux-x64.tar.gz on the official website,
Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2
, unzip the source package
Create a new Java folder from the terminal in the/usr/local directory, command line:
sudo mkdir /usr/local/java
Then copy the download to the archive into the Java folder, the command line:
Enter the directory where the JDK source package resides
CP jdk-8u66-linux-x64. tar. Gz/usr/local/java
Then go to the Java directory, command line:
Cd/usr/local/java
Unzip the Tarball, command line:
sudo tar zxvf jdk-8u66-linux-x64. tar. gz
You can then delete the compressed package, command line:
sudo RM jdk-8u66-linux-x64. tar. gz
3
, set the JDK environment variable
The global setting method here is to modify Etc/profile, which is a common environment variable for all users.
VI /etc/profile
After opening, add at the end
Java_home=/usr/local/java/jdk1. 8 . 0_66jre_home=/usr/local/java/jdk1. 8. 0_66/Jreclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/LibPATH = $JAVA _home/bin: $PATHexport PATH java_home CLASSPATH
Make environment variables effective
Source/etc/profile
See if your configuration is correct
Echo $JAVA _home Echo $CLASSPATH Echo $PATH
4
, modify the default JDK
If the system already has a different version of Java installed
Update-alternatives--install /usr/bin/java java/usr/java/jdk1. 8 - update-alternatives-install /usr/bin/javac javac/usr/java/jdk1. 8 - Update-alternatives--config javaupdate-alternatives--config Javac
5
, check whether the installation is successful
In the terminal
Java-version
To see if the installation was successful, the success is shown below
" 1.8.0_66 " 1.8. 0_66-25.65-b01, Mixed mode)
Reference:
Http://www.centoscn.com/image-text/install/2014/0827/3585.html
http://my.oschina.net/zhangjie830621/blog/280935
Linux (CentOS) installation jdk (. tar.gz) and configure
CentOS 6.5 Installation jdk1.8