Download jdk8
Here you can use Windows to download and then spread to the virtual machine
- Enter the jdk download page
https://www.oracle.com/technetwork/java/javase/downloads/index.html - Dropdown find JavaSE8, click on the download button at the right side of jdk
- Click consent agreement ○ Accept License Agreement
- Select the Linux jdk, here choose tar.gz way that the source installation
- Wait for the download to complete
jdk lead into the virtual machine
Here Xshell choose to use the tool Xftp
- First create a new folder, the directory is / usr / local / java
mkdir /usr/local/java (目录随意)
can also create a new folder in Xftp - Locate the downloaded on the left side of the Windows directory jdk source package, double-click the incoming Linux / usr / local / java directory
jdk decompression
- Command line into the / usr / local / java folder
cd /usr/local/java
- Decompression: tar zxvf archive name (for example:
tar zxvf jdk-8u191-linux-x64.tar.gz
) can enter a name following onlytar zxvf j
, and then auto-complete the Tab key file name - Delete archive: rm -f archive name (for example
rm -f jdk-8u191-linux-x64.tar.gz
)
Environment variable configuration
- Edit / etc / profile file
vi /etc/profile (root用户)
- Press
Insert
or theI
key is switched to the edit mode.
To find the end of the content, enter the following passage by picture.
Inunset i
front of input
export JAVA_HOME=/usr/local/java/jdk1.8.0_191
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
#(!!!注意:JAVA_HOME的路径是你实际解压后的JDK的路径,千万别写错了)
- According to
Esc
exit edit mode, enter:wq
to save and exit
- Environment variables to take effect
for the / etc / profile after the completion of the preparation is not enough, you also need the final step is to let us modify the file just becomes effective together, so we enter a command for the changes to take effect.
The entry into force command:source /etc/profile (root用户)
Verify that the installation was successful or not
Jdk installed user to log in again, execute the following command
java -version
Displays the version number is installed successfully
Author: moon ___
link: https: //www.jianshu.com/p/f000e05f3512
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.