ubuntu 安装 jdk7/8

1. 添加PPA

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

 2.安装oracle-java-installer

//jdk7

sudo apt-get install oracle-java7-installer
//jdk8

sudo apt-get install oracle-java8-installer

 3.设置系统默认jdk

//JDk7

sudo update-java-alternatives -s java-7-oracle
//JDK8

sudo update-java-alternatives -s java-8-oracle

 4.jdk之间的版本切换

 //jdk8 切换到jdk7

   sudo update-java-alternatives -s java-7-oracle
  //jdk7 切换到jdk8

   sudo update-java-alternatives -s java-8-oracle

 5.测试jdk 是是否安装成功

java -version

javac -version

相关推荐