Appium Doctor - unable to set $JAVA_HOME/bin into PATH variable on MacOS 10.12
Asked Answered
R

17

13

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
Rightness answered 25/10, 2016 at 3:56 Comment(2)
solved it on my ownRightness
Can you post your solution?Epilate
R
16

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
Rightness answered 27/10, 2016 at 5:35 Comment(0)
E
16

I needed to add

export PATH=${JAVA_HOME}/bin:$PATH

to ~/.bash_profile and restart the terminal

Epilate answered 27/10, 2016 at 1:39 Comment(1)
Make sure that JAVA_HOME doesn't have a trailing slash / on the end of the path, that's what caused an error for me as well.Ta
R
16

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
Rightness answered 27/10, 2016 at 5:35 Comment(0)
T
8

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
Tannin answered 5/4, 2017 at 20:31 Comment(0)
G
5
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
Gaberones answered 9/6, 2019 at 2:23 Comment(0)
G
2

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

Gwin answered 10/1, 2020 at 17:50 Comment(2)
Thank you! For some reason, Appium couldn't read JAVA_HOME path from my bash_profile but from Edit Configuration menu the field was empty and when I pasted /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home it started to work.Jackpot
What is the "Appium app?" I've installed Appium and there are nothing but command line tools.Leavening
F
1

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.

Futility answered 12/10, 2017 at 21:37 Comment(0)
G
1

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]

Greige answered 31/8, 2018 at 20:20 Comment(0)
D
1

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.

Durand answered 15/11, 2018 at 3:6 Comment(0)
V
1

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.

Voltaism answered 19/4, 2020 at 15:21 Comment(0)
M
1

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");
Madelenemadelin answered 26/6, 2020 at 6:47 Comment(0)
H
0

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

Heath answered 25/7, 2018 at 21:25 Comment(0)
L
0

macOS Mohave, v.10.14.6.

  1. vim ~/.bash_profile
  2. export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home

    export PATH=$JAVA_HOME/bin:$PATH

Lumper answered 8/12, 2019 at 10:16 Comment(0)
A
0

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.

Ably answered 20/4, 2020 at 9:4 Comment(0)
H
0

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

Heroism answered 21/4, 2020 at 14:50 Comment(1)
Welcome to StackOverflow, and thanks for your contribution! This is an answer to an already answered question. Please check: stackoverflow.com/help/how-to-answerCartwright
V
0

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

Validate answered 18/6, 2020 at 21:10 Comment(0)
R
0

Try restarting the system! I had the same issue and it got solved. I have even had other issues with appium that got solved again by restarting.

Reft answered 11/8, 2021 at 9:56 Comment(0)
T
0

Try adding the complete path i.e /Users/'your name'/Library/.......

This is what worked for me.

Tenorite answered 22/9, 2021 at 9:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.