Introduction:
Find java in linux and configure JAVA_HOME
Table of contents
1. Find java:
which java
output:
/usr/bin/java
find usr
ls -lr /usr/bin/java
output:
/usr/bin/java -> /etc/alternatives/java
find etc
ls -lrt /etc/alternatives/java
output:
/etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el7_9.x86_64/jre/bin/java
installation manual:
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el7_9.x86_64
Second, configure JAVA_HOME:
1. Open the file that configures the environment variables:
vi /etc/profile
2. Add the following configuration:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el7_9.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
3. Esc - :wq save and exit
4. Refresh the configuration to take effect:
source /etc/profile
5. Print address test
echo $JAVA_HOME