- Download the latest JDK version from Oracle with
- After downloading to get the file jdk-8u101-linux-x64.tar.gz (the file name may be different, the download extension is. tar.gz), the command line to enter the following code to extract the file to the current directory, you will get a folder named Jdk1.8.0_101
tar -zxvf jdk-8u101-linux-x64. tar. gz
- Create a new folder in the/usr/lib directory Java (requires root access)
cd/usr/libsudomkdir java
- Move Folder jdk1.8.0_101/to/usr/lib/java/
sudo MV Jdk1. 8. 0_101//usr/lib/java
- then enter the following 3-line command
sudoUpdate-alternatives--Install "/usr/bin/java" "Java" "/usr/lib/java/jdk1.8.0_101/bin/java" 1sudoUpdate-alternatives--Install "/usr/bin/javac" "Javac" "/usr/lib/java/jdk1.8.0_101/bin/javac" 1sudoUpdate-alternatives--Install "/usr/bin/javaws" "Javaws" "/usr/lib/java/jdk1.8.0_101/bin/javaws" 1
- Finally, set the environment variable, you need to edit the. bashrc file
sudo gedit ~/.BASHRC
Save it at the end of the file by adding 3 lines
#JAVA HOME directory setupexport java_home=/usr/lib/java/jdk1. 8 . 0_101export PATH="$PATH: $JAVA _home/bin"
Finally, the command line input java-version Test Installation Success!
Ubuntu 14.04 Installing Java JDK (6 steps)