1. Download the installation package
Official website download address: http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
Click Agree, then select the corresponding version, and download it
2. Install JDK
After downloading, unpack it through the command
sudo tar zxvf jdk-8u111-linux-x64.tar.gz
After unpacking
Create a directory /usr/lib/jvm to facilitate the download and decompression of the package in this directory.
sudo mkdir -p /usr/lib/jvm
Put the unzipped jdk1.8.0_25 folder into the /usr/lib/jvm directory. Note: I am downloading the jdk directory above.
sudo cp -r jdk1.8.0_111 /usr/lib/jvm
Enter the /usr/lib/jvm directory
cd /usr/lib/jvm
Rename the unzipped jdk1.8.0_25 folder to java for easier writing
sudo mv jdk1.8.0_111 jdk
Add environment variables
sudo gedit ~/.bashrc
Add the following content
export JAVA_HOME=/usr/lib/jvm/java export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH Enter the following code
source ~/.bashrc
An error was reported. I use zsh, configure ./bashrc, bashrc for bash to see, modify ./zshrc. . . .
sudo gedit ~/.zshrc
save
source ~/.zshrc
3. Test
enter:
java -version
javac -version
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.