• 在macOS 上添加 JAVA_HOME 环境变量


    If you are planing to develop Java Apps on your Mac, you may have to set $JAVA_HOME environment variable.

    Install the latest Java Virtual Machine

    Go to How to install JDK on Mac OS X to install a new Java Virtual Machine. Download the latest Java JDK package from Oracle.

    Check Java Virtual Machines

    List directories in the following root -> /Library/Java/JavaVirtualMachines

    $ ls -l /Library/Java/JavaVirtualMachines
    drwxr-xr-x  3 root  wheel  102 23 dic 20:36 jdk1.8.0_66.jdk
    drwxr-xr-x  3 root  wheel  102 21 mar 14:20 jdk1.8.0_74.jdk
    

    And the version for java will be the latest.

    $ java -version
    java version "1.8.0_74"
    Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
    
    Set JAVA_HOME environment variable

    Open your terminal, and create .bash_profile file if it does not exist.

    vim .bash_profile
    

    And write the following:

    export JAVA_HOME=$(/usr/libexec/java_home)
    

    Refresh the environment variables by running the following command, and check the $JAVA_HOME value:

    $ source .bash_profile
    $ echo $JAVA_HOME
    /Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home



    简单的说就是先安装JDK,然后找到 .bash_Profile (因为我不会用vim)。
    在最后一行添加

    export JAVA_HOME=$(/usr/libexec/java_home)

    然后在命令行里输入
    source .bash_profile

    然后查看结果:
    echo $JAVA_HOME



  • 相关阅读:
    仿MSN小类别滑动效果
    pku1674 Sorting by Swapping
    pku1456 Supermarket
    pku1083 Moving Tables
    pku1125 Stockbroker Grapevine
    pku2232 New StoneForfexCloth Game
    如何低头前进
    和两年前一样
    股票亏了
    早上选举了
  • 原文地址:https://www.cnblogs.com/googlegis/p/9776301.html
Copyright © 2020-2023  润新知