1.安置好你的tar版的jdkjava
2.運行命令:bash
sudo gedit ~/.bashrc
從而用gedit編輯~/.bashrc來設置環境變量:code
export JAVA_HOME=/your/path/to/jdk export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib export PATH=${JAVA_HOME}/bin:$PATH
3.運行命令:it
sudo update-alternatives --install /usr/bin/java java /your/path/to/jdk/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /your/path/to/jdk/bin/javac 300
4.運行命令按提示選擇你的tar版jdk:變量
sudo update-alternatives --config java