orcle jdk linux 安装教程

  1. 将*.tar.gz解压(以jdk8.144为例):

    tar -xzvf jdk-8u144-linux-x64.tar.gz
    1. 得到的文件夹为jdk1.8.0_144,将其移动到/usr/lib/jvm中: bash sudo mv jdk1.8.0_144 /usr/lib/jvm
  2. 设置环境变量:

    sudo gedit /etc/profile

    打开文件,在结尾处输入:

    export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_144
    export JRE_HOME=/usr/lib/jvm/jdk1.8.0_144/jre
    export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
    export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
  3. 生效配置文件:

source /etc/profile
  1. 创建jdk软链接:
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_144/bin/java 300
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_144/bin/javac 300
  1. 设置默认jdk:
update-alternatives --config java
  1. 查看jdk版本,检查是否安装完成:
java -version