Mr. Robot
Mr. Robot

Reputation: 1824

ERROR: JAVA_HOME is set to an invalid directory: /usr/libexec/java_home (Mac OSX)

When I run react-native run-android I get the error ERROR: JAVA_HOME is set to an invalid directory: /usr/libexec/java_home.

I add the Java home path to my bash profile like this:

export JAVA_HOME=$(/usr/libexec/java_home).

When I paste this and hit enter in the terminal:

/usr/libexec/java_home,

I get this:

/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home.

But when I run react-native run-android, I still get the error.

It's driving me absolutely mad and I don't know how to fix it.

Any ideas hugely appreciated.

Upvotes: 3

Views: 9099

Answers (1)

hong developer
hong developer

Reputation: 13926

Set the value you get.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home

export CLASSPATH=.:$JAVA_HOME/lib/tools.jar

Upvotes: 6

Related Questions