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
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
SergioLeone
  • 734
  • 1
  • 10
  • 24

17 Answers17

16

I needed to add

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

to ~/.bash_profile and restart the terminal

Ryan Knell
  • 6,204
  • 2
  • 40
  • 32
  • 4
    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. – Joshua Pinter Sep 09 '17 at 19:09
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
SergioLeone
  • 734
  • 1
  • 10
  • 24
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
manman
  • 4,743
  • 3
  • 30
  • 42
5
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
mabahamo
  • 684
  • 10
  • 10
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

Community
  • 1
  • 1
Naval Kishor Jha
  • 894
  • 9
  • 13
  • 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. – Andrii Artamonov May 25 '20 at 17:44
  • What is the "Appium app?" I've installed Appium and there are nothing but command line tools. – Jeff Wright Jun 26 '20 at 12:40
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.

Souparno
  • 350
  • 1
  • 5
  • 18
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]

MBT
  • 21,733
  • 19
  • 84
  • 102
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.

Mysterious_android
  • 598
  • 2
  • 9
  • 32
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.

Adamantus
  • 813
  • 1
  • 12
  • 30
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");
Meer
  • 678
  • 6
  • 12
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

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
Amar
  • 1
  • 3
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

Anatoliy_Z
  • 129
  • 1
  • 4
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.

Lutenist
  • 11
  • 4
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

  • Welcome to StackOverflow, and thanks for your contribution! This is an answer to an already answered question. Please check: https://stackoverflow.com/help/how-to-answer – Tu.Ma. Apr 21 '20 at 15:00
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

Nikhil Raj LR
  • 83
  • 1
  • 6
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.

Alex
  • 1
0

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

This is what worked for me.

Raghu K
  • 57
  • 1
  • 10