150

I have a very simple question. I am brand new to Mac and I am trying to get my Java project moved over to my new Mac. The project has a Gradlew file that I thought I could run from the command line to build and run on any machine. When I do gradlew from the command line (in the location of the gradlew file) it says gradlew not found. Am I missing something on how to run a command from a bash shell?

Barodapride
  • 3,475
  • 4
  • 25
  • 36

3 Answers3

265

./gradlew

Your directory with gradlew is not included in the PATH, so you must specify path to the gradlew. . means "current directory".

Alex Filatov
  • 4,768
  • 2
  • 16
  • 10
  • 90
    Also if you get "./gradlew: Permission denied" using Mac Terminal you need to run `chmod 755 gradlew` first. – David Douglas Jun 18 '15 at 09:43
  • 9
    gradlew can be found in the project's root folder. added this comment because i couldn't find out! – Lou Morda Jan 11 '16 at 02:41
  • 1
    Just my two cents, for those that still couldn't get it work and had followed the steps provided by Alex, at your directory, open terminal and run "./gradlew" and not "gradlew".. Works for me – ramen87x Jul 04 '22 at 09:09
115

Also, if you don't have the gradlew file in your current directory:

You can install gradle with homebrew with the following command:

$ brew install gradle

As mentioned in this answer. Then, you are not going to need to include it in your path (homebrew will take care of that) and you can just run (from any directory):

$ gradle test 
Community
  • 1
  • 1
Evin1_
  • 12,292
  • 9
  • 45
  • 47
  • 7
    Pardon my ingorance here, but the OP wanted `gradlew` not `gradle` --am I missing something about the relationship between the two? – MarkHu Nov 12 '16 at 05:58
  • 12
    gradlew is a generated gradle wrapper for a project. The wrapper makes the project self contained and independent of the OS installed Gradle version. The Gradle wrapper documentation is found here: https://docs.gradle.org/current/userguide/gradle_wrapper.html – Chris Khoo Feb 07 '17 at 15:52
  • 1
    so if I need to use gradlew just type gradle and it's ok? – Qube Jul 14 '20 at 13:14
  • 2
    I would use `gradlew` if it exists on the current path since it's a version tailored to a project and a specific distribution. Use `gradle` if the `gradlew` file can't be found. – Evin1_ Jul 15 '20 at 11:40
0

try this cmd

git:(branch): cd android

android git:(branch) ./gradlew gradle build --scan

jeany
  • 89
  • 1
  • 3