ubuntu中将java环境由安装版的openjdk替换为tar版的jdk

630 查看

1.安置好你的tar版的jdk

2.运行命令:

sudo gedit ~/.bashrc

从而用gedit编辑~/.bashrc来设置环境变量:

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.运行命令:

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