installation path
[hadoop@192 /]$ which java
/bin/java
[hadoop@192 /]$ ls -lrt /bin/java
lrwxrwxrwx. 1 root root 22 4月 17 06:25 /bin/java -> /etc/alternatives/java
[hadoop@192 /]$ ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 72 4月 17 06:25 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64/jre/bin/java
[hadoop@192 /]$
rpm -ql java-1.7.0-openjdk-devel | grep '/bin/javac'
Configure the environment variables (Global)
Placed JAVA_HOME
- Open the configuration file environment variables
vi /etc/profile.d/java.sh
- Add the following configuration:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
: Wq save and exit.
- Let configuration to take effect
source /etc/profile.d/java.sh
- Test Configuration
echo $JAVA_HOME
Supplementary: / etc / profile and the difference between /etc/profile.d
- Both are set environment variables
- /etc/profile.d/ than / etc / profile good maintenance, do not want to delete /etc/profile.d/ under what variables corresponding to the shell script, do not like / etc / profile need to change the file
below to the jdk installation Case Study
vi /etc/profile.d/java.sh Enter the following in a new java.sh in:
#set java environment
JAVA_HOME=/var/mysoft/jdk1.7.0_80
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
Save and exit, and then assign permissions to java.sh: chmod 755 /etc/profile.d/java.sh
echo $JAVA_HOME