centos 7.0. Installation of offline JDK1.8 Detailed method
- 2020-10-07 18:59:07
- OfStack
View the java warehouse version
yum list |grep java
View installed versions of java jdk
rpm -qa | grep java
If no information is displayed, the jdk version has not been installed
If the following information is displayed:
rpm -qa|grep jdk
java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
Uninstall command
yum -y remove java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
The Java command is not recognized after the uninstall completes
java -version
bash: java: command not found...
Start the installation
Go to the website to download jdk: http: / / www oracle. com/technetwork/java/javase downloads/jdk8 - downloads - 2133151. html
Unzip to the installation directory
The current version is jdk1.8.172
jdk-8u172-linux-x64.gz
Create installation directory
cd home;
adduser hadoop;
passwd hadoop;
whereis sudoers
ls -l /etc/sudoers
Add writable permissions
chmod -v u+w /etc/sudoers
Then edit the /etc/sudoers file
vi /etc/sudoers
Add the following hadoop code:
Allow root to run any commands anywhere
root ALL=(ALL) ALL
hadoop ALL=(ALL) ALL #this is new add user
// -- -- -- -- -
ls -l /etc/sudoers
Remove writable permissions
chmod -v u-w /etc/sudoers
sudo -u hadoop
sudo cat /etc/passwd
hadoop users are now sudo authorized users.
tar -zxvf jdk-8u172-linux-x64.gz -C /home/hadoop/java/
Change directory name
mv jdk1.8.0_172/ jdk1.8/
Go to the jdk folder and get the absolute directory path
pwd
[root@hadoop-localhost jdk1.8]# pwd
/home/hadoop/java/jdk1.8
(my absolute path is: / home/hadoop java/jdk1. 8)
jdk configuration
Use the vim command to open the system's environment variable configuration file:
vi /etc/profile
At the end of profile file, add:
//## JAVA
export JAVA_HOME=/home/hadoop/java/jdk1.8
//jdk The absolute path of (mine is: /home/hadoop/java/jdk1.8 )
export PATH=PATH:
PATH:
JAVA_HOME/bin
jdk configuration validation
Enable the configuration file first
source /etc/profile
[root@hadoop-localhost jdk1.8]# source /etc/profile
java -version
[root@hadoop-localhost jdk1.8]# java -version
java version " 1.8.0_172 "
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
conclusion