Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 824
SergioLeone Avatar asked Oct 25 '16 03:10

SergioLeone


People also ask

What should be the path of JAVA_HOME in Mac?

JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java. For Mac OSX – it is /Library/Java/Home.

Why is JAVA_HOME not set?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.

How do I add Java<UNK>home to PATH variable in Mac?

In Mac OSX 10.5 or later, Apple recommends to set the $JAVA_HOME variable to /usr/libexec/java_home , just export $JAVA_HOME in file ~/. bash_profile or ~/. profile .


2 Answers

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");
like image 121
Meer Avatar answered Oct 10 '22 23:10

Meer


export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
like image 41
mabahamo Avatar answered Oct 11 '22 00:10

mabahamo