Linux
打开/etc/profile
, 添加如下代码:
export JAVA_HOME=/opt/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
执行代码,使配置生效
source /etc/profile
安装命令 需要root权限
alternatives --install /usr/bin/java java /opt/jdk/bin/java 1600
alternatives --install /usr/bin/javac javac /opt/jdk/bin/javac 1600
Windows
windows下,path路径以
;
分割,bat变量%JAVA_HOME%