#编辑JDK8
export JAVA_HOME="/usr/java/java8"
#编辑maven
export M2_HOME="/opt/idea-IU-162.1121.32/plugins/maven/lib/maven3"
#编辑PATH
export PATH="$JAVA_HOME/bin:$M2_HOME/bin:$PATH"
This is the configuration at the end of my /etc/profile. There is no problem with JDK, no source is needed, and echo $JAVA_HOME can come out. The problem is that if you want to use mvn, you need to source it every time. I use IDEA for maven. with.
Answer 1. It can also be placed in ~/.bashrc. Or add a source /etc/profile to ~/.bashrc
( This method has been used successfully )