Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

./gradlew The operation couldn’t be completed. Unable to locate a Java Runtime

When I run ./gradlew from project folder I get:

./gradlew
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

The same with java:

which java
/usr/bin/java

/usr/bin/java
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

I installed JDK in Android studio, seems it's installed in ~/Library/Android/sdk/sources/android-28

Setting export JAVA_HOME=/Users/mrgloom/Library/Android/sdk/sources/android-28/ or export JAVA_HOME=/Users/mrgloom/Library/Android/sdk produce error like:

ERROR: JAVA_HOME is set to an invalid directory: /Users/mrgloom/Library/Android/sdk/sources/android-28/

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

How to specify java path for gradlew ?

like image 227
mrgloom Avatar asked Aug 09 '21 10:08

mrgloom


People also ask

Why does my Mac say unable to locate a java Runtime?

The message “Unable to load Java Runtime Environment” means that the Mac computer cannot load JRE, either because it is out of date or (more usually) because it has not yet been downloaded and installed. It can also happen after the computer OS X has been updated, e.g. to 10.14 Mojave from 10.13 Maverick.

Where is java runtime on Mac?

Determining the JRE Version Installed on macOSFrom System Preferences, and then the Other section, click the Java icon. This starts the Java Control Panel. You then click About to display the version information.


1 Answers

Using JDK shipped with Android Studio and setting export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home helped me.

like image 56
mrgloom Avatar answered Oct 18 '22 23:10

mrgloom