First, install jdk8
- Download the JDK tar.gz package
Official website to download the latest JDK:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- Extracting archive
Download directory
cd ~/Download
Unzip tar.gz package
tar -zxvf jdk-8u171-linux-x64.tar.gz
Install the JDK
sudo mv jdk-8u171-linux-x64/ /usr/lib/jvm/jdk1.8.0_171
JDK environment variable configuration
- Modify the configuration file
sudo vim /etc/profile
Increase content at the end of the file
-
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_171
-
export JRE_HOME=${JAVA_HOME}/jre
-
export CLASSPATH=.:${JAVA_HOME}/lib:${JAVA_HOME}/lib
-
export PATH=${JAVA_HOME}/bin:$PATH
Note that the path and version of jdk
- Validate the configuration
source /etc/profile
test
- View JAVA version
In the terminal execute the following command
java -version
Export
-
java version "1.8.0_171"
-
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
-
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
In the terminal on the implementation of java and javac commands have the correct feedback, the installation is successful, it ended.