问题
Installed appium doctor with npm on MacOS 10.12, and it gives me one error:
WARN AppiumDoctor ✖ Bin directory for $JAVA_HOME is not set.
I've tried everything I could so far, please help. Here is my .bash_profile:
export ANDROID_HOME="/Users/sergei/Library/Android/sdk/"
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export M2_HOME="/Users/sergei/Desktop/1246702 Sergio/apache-maven-3.3.9"
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JYTHON_HOME="/Users/sergei/jython2.7.0/"
export JYTHON=JYTHON_HOME/bin
export PATH=JYTHON:$PATH
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
回答1:
I needed to add
export PATH=${JAVA_HOME}/bin:$PATH
to ~/.bash_profile and restart the terminal
回答2:
I removed double quotes from the paths and slashes from the end This is working fine for me now:
export ANDROID_HOME=/Users/sergei/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
回答3:
This looks to be an old post, but for future viewers, I found this solution better due to it doesn't hardcode java sdk path.
JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
回答4:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
回答5:
For me After Adding JAVA_HOME
and ANDROID_HOME
in ~/.bash_profile
file as export
and in PATH
export ANDROID_HOME=/Library/YourUserName/Library/Android/sdk
export PATH="$PATH:$ANDROID_HOME:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
export PATH="$PATH:$JAVA_HOME/bin"
in your terminal just type this
source ~/.bash_profile
Still I need to re-start the Appium server then it worked.
But Appium has given the easy feature to save the user time
Open the Appium app and then You can Click on the"Edit Configurations"
Button
A dialog/pop window will appear and where you can add two parameter
- ANDROID_HOME
- JAVA_HOME
path(same as above) in the editText. then Click on
"Save and Restart"
again click on"restart now"
button in the pop window and
you are done once Appium is restarted an up and
no need to deal with bash_profile or any command
回答6:
I was making a rookie mistake and want to add it here so people dont repeat my mistake.
Instead of exporting $PATH and $JAVA_HOME, i was sourcing it from my /etc/environment file. As a result both showed up correct when I would use echo but my Appium install could not find it.
Then i found this out : Unix: What is the difference between source and export?
Basically you gotta export the variables from your bashrc so they get added to your global environment and appium can then access it.
回答7:
Lots of correct answers should be working for someone and for not for some.
I recommend trying solution form official developer support.
JAVA_HOME=/usr/java/j2sdk1.5.0
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH;
export PATH
try this should work like a charm. [https://docs.oracle.com/cd/E19575-01/820-5019/ghhls/index.html][1]
回答8:
My problem was I forgot to close the terminal and restart it. When you finish adding the JAVA_HOME/Bin
to PATH in the environment variables click OK and close and don't forget to also close all your terminals.
After opening your terminal again, it should be updated and running appium-doctor will see the updated Environmental variable.
回答9:
The answer to this is to add C:\Program Files\Java\jdk-14.0.1\bin to your PATH variable.
It's not complaining about JAVA_HOME, it just wants the bin directory adding to path.
Afterwards restart your command line as administrator. I realize this is for Windows, but I think it's the same problem as I was getting.
回答10:
I tried different things, everything was ok, but this file "Bin directory of $JAVA_HOME is not set" stayed. After that i wrote npm uninstall appium-doctor
in bash, and after that everything was ok... you can try uninstall, then npm install appium-doctor
回答11:
macOS Mohave, v.10.14.6.
- vim ~/.bash_profile
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
回答12:
There is a settings menu in the Appium GUI ("Edit configurations" on Mac) where you can enter the path. This is what fixed it for me.
回答13:
Terminal:vim .bash_profile
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_HOME=/Users/sharadgupta/Documents/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Add only above 4 lines
回答14:
Android and JAVA path setup for Appium for Mac:
Open Terminal and type vi ~/.profile
(If super user permission needed use sudo)-> This will open profile file.
click i
or insert
button for edit the file.
add below contents to the .profile file(Change Android Home based on your SDK installation path):
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_HOME=/Users/<userdirectory>/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Click ESC button and :wq
and Enter (Will save the changes and quit the file.)
In Terminal type: source ~/.profile
(To apply changes to the .profile
file)
Test Configuration:
In Terminal type: $echo JAVA_HOME
(Check the output, and test other values we configured in .profile
file)
Now run again to find the status: appium-doctor --android
回答15:
Leaving the solution here, incase anyone faced similar problem in Mac Catalina, when running Appium C# script to initialise Android driver. Tried fixing .bash_profile and .zprofile files as mentioned in many answers, nothing seem to work.
Then, decided to explicitly set ANDROID_HOME and JAVA_HOME environment variables programmatically as follows, before initialising Android driver, it finally worked:
Environment.SetEnvironmentVariable("ANDROID_HOME", "/Users/{username}/Library/Android/sdk");
Environment.SetEnvironmentVariable("JAVA_HOME", "/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home");
来源:https://stackoverflow.com/questions/40231125/appium-doctor-unable-to-set-java-home-bin-into-path-variable-on-macos-10-12