Here's a detailed look at the process of configuring the JDK under CentOS
First, in accordance with the customary practice, put the JDK under/usr/local/java, first enter/usr/local and then create a new directory Java
Then we need to download the latest JDK package, can be downloaded locally and uploaded to the server can also be downloaded directly from the server, if downloaded locally, should visit the Oracle official website download page
URL is: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Click Java Platform (JDK) 8u65/8u66 download to get to the latest version download page
Then choose Agree Agreement, download the corresponding Linux version, I download here is: 64-bit jdk-8u65-linux-x64.tar.gz
After downloading, upload to the server, or directly with the command line to download, but not directly with the wget URL to download, because there is no agreement this step, so you should set a consent protocol HTTP header used to send a cookie request, the command is as follows:
wget " Cookie:oraclelicense=accept-securebackup-cookie; " http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.tar.gz
The next is the download link, and now a little wait for the screen scroll progress bar download is ready
Then we release the archive file:
tar xvf jdk-8u65-linux-x64. tar. gz
Once released, you can see the directory and you can now delete the downloaded. tar.gz file.
Release complete even if the installation, the next configuration environment variables can be, with vim open/etc/profile file for global configuration
Vim/etc/profile
After opening the cursor moves to the last line, into the edit mode, the last line may have the original configured path, so we first append a colon after path:, and then append $java_home/bin, and then continue to edit another line:
Java_home=/usr/local/java/jdk1. 8 . 0_65jre_home=/usr/local/java/jdk1. 8. 0_65/Jreclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/Libexport Java_home jre_home CLASSPATH
Here more configuration of a jre_home back to write more simple, in fact, can be their own flexible definition, the path is written on the top can avoid the old version of the problem, because the environment variable file system read is sequential loading, of course, we are here is pure system installation JDK
Now that the environment variable is configured, save and exit Vim, and then use the source command to make the file effective immediately.
Source/etc/profile
OK, to now JDK all done, now in any place input Java, java-version, Javac can be executed correctly, you can also compile a simple source file to try
Configuring JDK under CentOS