One. Download JDK
Download JDK to Oracle website (www.oracle.com)
Two. Unzip the installation
Create a new directory under/USR/java
1.cd/usr
2.sudo mkdir Java
Access to the downloaded JDK directory via the CD command
sudo tar zxvf./jdk-8u91-linux-x64.tar.gz-c/usr/java
Three. Configure environment variables (environment variables that work for all users)
Modify the/etc/profile file if your computer is only used as a developer when using this method, because all the user's shell has the right to use this environment variable, may bring security issues to the system
Vi/etc/profile
Add at the end of an open file
Export java_home=/usr/java/jdk1.8.0_91
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH
Four. Configure the default JDK (typically this step can be omitted)
In order to make the JDK version we just installed can be the default JDK version, we will also make the following configuration.
1.sudo update-alternatives--install/usr/bin/java Java/usr/java/jdk1.8.0_91/bin/java 300
2.sudo update-alternatives--install/usr/bin/javac Javac/usr/java/jdk1.8.0_91/bin/javac 300
Five. Testing
Java-version
The results shown below indicate that the Java command is ready to run
Java Version "1.8.0_91"
Java (TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot (TM) 64-bit Server VM (build 25.91-b14, Mixed mode)
Install configuration JDK under Linux