美文网首页
Ubuntu安装Oracle JDK

Ubuntu安装Oracle JDK

作者: heichong | 来源:发表于2019-01-08 11:13 被阅读6次

    查看是否已安装jdk

    以下信息说明未安装

    ubuntu@VM-16-6-ubuntu:/var$ java -version
    The program 'java' can be found in the following packages:
     * default-jre
     * gcj-5-jre-headless
     * openjdk-8-jre-headless
     * gcj-4.8-jre-headless
     * gcj-4.9-jre-headless
     * openjdk-9-jre-headless
    Try: sudo apt install <selected package>
    

    执行以下命令进行安装

    ubuntu@VM-16-6-ubuntu:/var$ sudo apt-get install python-software-properties
    
    ubuntu@VM-16-6-ubuntu:/var$ sudo add-apt-repository ppa:webupd8team/java
    
    ubuntu@VM-16-6-ubuntu:/var$ sudo apt-get update
    
    ubuntu@VM-16-6-ubuntu:/var$ sudo apt-get install oracle-java8-installer
    

    最后一个命令会弹出图形化界面,主要是让你接受Jdk License

    设置 $JAVA_HOME

    1. 查看java路径
    ubuntu@VM-16-6-ubuntu:~$ sudo update-alternatives --config java
    There is 1 choice for the alternative java (providing /usr/bin/java).
    
      Selection    Path                                     Priority   Status
    ------------------------------------------------------------
      0            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      auto mode
    * 1            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      manual mode
    

    copy上面path路径/usr/lib/jvm/java-8-oracle/jre/bin/java

    1. 更新配置
    sudo vi /etc/environment
    

    在文件内插入一行JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre/bin/java"

    ubuntu@VM-16-6-ubuntu:~$ source /etc/environment
    ubuntu@VM-16-6-ubuntu:~$ echo $JAVA_HOME
    /usr/lib/jvm/java-8-oracle/jre/bin/java
    

    安装完成

    相关文章

      网友评论

          本文标题:Ubuntu安装Oracle JDK

          本文链接:https://www.haomeiwen.com/subject/dozmrqtx.html