编程语言
首页 > 编程语言> > macOS 系统输入 appium-doctor后提示JAVA_HOME 环境变量未设置的解决办法

macOS 系统输入 appium-doctor后提示JAVA_HOME 环境变量未设置的解决办法

作者:互联网

【问题描述】

在macOS 系统安装好 APPium之后,随即安装appium-doctor

而后输入 appium-doctor,检查安装情况,提示:JAVA_HOME 环境变量未设置。

如下所示:

  

 

 

【解决办法】

   在macOS系统上设置环境变量:

    (参考博客: macOS系统 在~/.zshrc 中配置java环境变量: https://www.cnblogs.com/hf-cherish/p/5603147.html 

1、首先检查一下 Java 是否安装

      

 

 

2、根据以下提示输入命令:

    

 

 

     

 

 

 设置好了之后,输入 “ :wq” 退出。

      

 

 

 

 

 

检查Java_home是否设置成功:

      

 

 

输入的命令如下所示:

➜  ~ ## check all the available jdk
➜  ~ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.281.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_201 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
➜  ~ ## check the top jdk
➜  ~ /usr/libexec/java_home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
➜  ~ ## check some jdk
➜  ~ /usr/libexec/java_home -v 1.7
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
➜  ~ ## edit .zshrc to set java_home variable
➜  ~ vim ~/.zshrc
➜  ~ ## Have opened .zshrc and added JAVE_HOME variable,now come back
➜  ~ ## Have opened .zshrc and added JAVE_HOME variable,now come back to here
➜  ~ ## let the configuration in .zshrc take effect
➜  ~ source ~/.zshrc
npm WARN npm npm does not support Node.js v14.15.4
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.11.4 --silent` to unset it.
➜  ~ ## check if configure succeed
➜  ~ echo $JAVA_HOME
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
➜  ~ echo $ANDROID_HOME
/Users/crgt/Downloads/android-sdk-macosx
➜  ~

 

 

最后是这样:(必须的“依赖”都已经安装完成)

    

 

标签:npm,macOS,JAVA,doctor,##,zshrc,Home,Java,Contents
来源: https://www.cnblogs.com/shenxiaolin/p/14383190.html