Install jdk on centos7
1. Download jdk
Http://www.oracle.com/technetwork/Java/javase/downloads/jdk8-downloads-2133151.html
(Based on the number of digits in the operating system, select the corresponding version, 32-bit select x86, 64 select x64)
2. Upload to centos
2.1 install the upload tool lrzsz and run yum install lrzsz on the command line.
2.2 cd to the uploaded destination directory
2.3 run rz on the command line and select the tar package downloaded in step 1.
2.4 decompress the file to/usr/local/
2.5 switch to the decompressed directory, pwd
3. The above path will be used as the value of the JAVA_HOME environment variable and configured to/etc/profile
Vi/etc/profile
In normal mode, press G to jump to the end of the file, and press o to add the following two lines
Export JAVA_HOME =/usr/local/jdk1.8.0 _ 121
Export PATH = $ PATH: $ JAVA_HOME/bin
The effect is as follows:
4. Execute source/etc/profile to refresh the environment variable you just set to the current shell.
Here, I will post the source explanation below man.
Man source
4.1 check whether the environment variables take effect
Echo $ JAVA_HOME
Echo $ PATH
5. check whether it is successful
Java-version
The configuration is OK.