zoukankan      html  css  js  c++  java
  • 【JAVA】mac配置java环境变量

    如果用bash,修改~/.bash_profile 或 ~/.profile;

    如果用zsh,修改~/.zshrc

    修改这些文件之后,重修打开terminal,配置不会丢 

    首先确保已经安装了jdk:

    ## check the present running java
    which java
    
    ## check java version
    java -version

    以zsh为例:
    ## check all the available jdk
     2 /usr/libexec/java_home -V
     3 
     4 ## check the top jdk
     5 /usr/libexec/java_home
     6 
     7 ## check some jdk (eg. version 1.7)
     8 /usr/libexec/java_home -v 1.7
     9 
    10 ## edit .zshrc to set java_home variable
    11 vim ~/.zshrc
    12 
    13 ## add the following line into the file
    14 export JAVA_HOME=$(/usr/libexec/java_home)
    15 
    16 ## you can also use the following line to set the variable, which is not recommended, only for older mac os.
    17 ## export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    18 
    19 ##let the configuration in .zshrc take effect
    20 source ~/.zshrc
    21 
    22 ## check if configure succeed
    23 echo $JAVA_HOME
  • 相关阅读:
    vue跨域代理配置
    vue中引入jquery
    vue中使用特殊字体
    vue中使用mockjs
    vue中使用动态echart图表
    解决win10休眠后无法唤醒
    nvm-windows的安装配置
    黑苹果快捷键
    python基础知识
    如何高效的学习python
  • 原文地址:https://www.cnblogs.com/zengweiming/p/9183259.html
Copyright © 2011-2022 走看看