Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 267
Mr. Robot Avatar asked Feb 04 '26 15:02

Mr. Robot


1 Answers

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
like image 148
hong developer Avatar answered Feb 09 '26 09:02

hong developer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!