First, download the JDK
1 wget http://download.oracle.com/otn-pub/java/jdk/8u25-b17/ jdk-8u25-linux-x64.tar.gz
(Note: If the download is not open, you can download it from the JDK website)
Second, decompression and installation
1 sudo mkdir /usr/lib/JVM2sudotar -zxvf jdk-8u25-linux-x64. tar. Gz-c/USR/LIB/JVM
Third, modify the environment variables
1 sudo vim/etc/profile
(Note: Vim is a text editor, Ubuntu is not installed by default, you can use Gedit instead)
Add to:
1 #set Java Environment 2 Export JAVA_HOME=/USR/LIB/JVM/JDK1. 8 . 0_25 3 export jre_home=${java_home}/4 export classpath=.:${java_home}/lib:${jre_home}/ Lib5 export Path=${java_home}/bin: $PATH
Save exit.
Iv. Configuring the default JDK version
To set up our installed JDK as the default JDK, do the following. (300 indicates the priority of the JDK)
1 sudo update-alternatives--install /usr/bin/java java/usr/lib/jvm/java-7 2sudo update-alternatives--install /usr/bin/javac javac/usr/lib/jvm/java-7 -
Execute code:
1 sudo
If there are multiple JDK will be listed, the native only one, shown as follows:
Multiple JDK will appear as follows (image from Network):
V. Testing
Enter in terminal
1 java-version
Shown below:
Indicates that the JDK environment is configured to complete.
You can also test the following commands:
1 Java 2 Javac
Ubuntu-14.04.1-desktop Install configuration JDK1.8 environment variables on the