阿里云Ubuntu服务器安装JDK

安装 JDK

  1. 官网地址
    https://www.oracle.com/java/technologies/javase-jdk13-downloads.html

  2. 下载安装包
    自己想办法下载吧,我是通过 git 传过去的...

  3. 解压 jdk
    tar -xzf jdk-13.0.2_linux-x64_bin.tar_2.gz

  4. 移动到目录 /usr/lib/jvm/

    sudo mkdir /usr/lib/jvm
    sudo mv jdk-13.0.2 /usr/lib/jvm/
    
  5. 配置环境变量, 编辑文件 /etc/profile, 在末尾添加
    vi /etc/profile

    # jdk config
    export JAVA_HOME=/usr/lib/jvm/jdk-13.0.2
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    export PATH={JAVA_HOME}/bin:$PATH
    
  6. 使环境变量生效
    source /etc/profile

  7. 配置jdk

    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-13.0.2/bin/java 300
    sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-13.0.2/bin/javac 300
    sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk-13.0.2/bin/javap 300 
    sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk-13.0.2/bin/javafoc 300
    
  8. 安装成功
    java -version

你可能感兴趣的:(阿里云Ubuntu服务器安装JDK)