1、编辑 ~/.bash_profile
命令如下:
vi ~/.bash_profile
内容修改如下:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export JAVA_HOME=/usr/local/jdk1.8.0_191
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
备注:jdk的路径根据实际情况进行修改
2、使 ~/.bash_profile 生效
命令如下:
source ~/.bash_profile
3、验证
1)查看JDK版本
命令如下:
java -version
2)验证 javac 命令