http://ubuntuhandbook.org/index.php/2015/01/install-openjdk-8-ubuntu-14-04-12-04-lts/
安装OpenJDK8
sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-8-jdk
切换方法
sudo update-alternatives --config java sudo update-alternatives --config javac
如果是下载的安装包,不是apt-get install,可以这样配置
1. 配置环境变量,在文件etc/profile中添加: set java environmentexport JAVA_HOME=/usr/local/jdk1.8.0_91 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH 2. 安装 sudo update-alternatives --install /usr/bin/java java /usr/local/jdk1.8.0_91/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8.0_91/bin/javac 300
也可以remove
sudo update-alternatives --remove java /usr/local/jdk1.8.0_91/bin/java sudo update-alternatives --remove javac /usr/local/jdk1.8.0_91/bin/javac
时间: 2024-11-05 22:00:53