ubuntu15.04安装java8

  • 下载并解压JDK

      http://www.oracle.com/technetwork/cn/java/javase/downloads/index.html
    
  • 移动JDK

      # mv jdk1.8.0_20 /usr/local
    
  • 设置JDK环境变量

      # vi /etc/profile
    
      export JAVA_HOME=/usr/local/jdk1.8.0_20
      export JRE_HOME=${JAVA_HOME}/jre
      export CLASSPATH=.:{$JAVA_HOME}/lib:{$JRE_HOME}/lib
      export PATH=${JAVA_HOME}/bin:$PATH
    
      # source /etc/profile # 立即生效
    
  • 设置默认

      sudo update-alternatives --install /usr/bin/java java  /usr/local/jdk1.8.0_20/bin/java  300
      sudo update-alternatives --install /usr/bin/javac javac  /usr/local/jdk1.8.0_20/bin/javac  300
    
  • 验证

      sudo update-alternatives --display java # 查看信息默认的jdk信息