假设将jdk解压到/opt/jdk1.8.0_131.
echo "export JAVA_HOME=/opt/jdk1.8.0_131" >> /etc/profile echo "export JRE_HOME=${JAVA_HOME}/jre" >> /etc/profile echo "export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib" >> /etc/profile echo "export PATH=${JAVA_HOME}/bin:$PATH" >> /etc/profile