View java warehouse version
yum list |grep java
Check the installed java jdk version
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
Java commands are not recognized after uninstallation is complete
java -version
bash: java: command not found…
start installation
Go to the official 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 write permission
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 newadd user
//—————————
ls -l /etc/sudoers
Remove writable permissions
chmod -v u-w /etc/sudoers
sudo -u hadoop
sudo cat /etc/passwd
Now the hadoop user is a user with sudo privileges.
tar -zxvf jdk-8u172-linux-x64.gz -C /home/hadoop/java/
Change directory name
mv jdk1.8.0_172/ jdk1.8/
Enter the jdk folder and get the absolute path of the directory
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
Add at the end of the profile file:
//## JAVA export JAVA_HOME=/home/hadoop/java/jdk1.8//The absolute path of jdk (mine is:/home/hadoop/java/jdk1.8)export PATH=PATH:
PATH:
JAVA_HOME/bin
jdk configuration verification
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)
to sum up
The above is the centos7.0 installation offline JDK1.8 method introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
Recommended Posts