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、根據以下提示輸入命令:

    

 

 ## add the following line into the  .zshrc file :
export JAVA_HOME=$(/usr/libexec/java_home)

     

 

 設置好了之后,輸入 “ :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/XXXX/Downloads/android-sdk-macosx
➜  ~

 

 

最后是這樣:(必須的“依賴”都已經安裝完成)

    

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM