Home > Mobile >  Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain in MacOs
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain in MacOs

Time:08-01

I have simple java gradle project and use gradle wrapper to run it. However when I run ./gradlew run I get:

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

Removing wrapper and generating it again did not help.

CodePudding user response:

I spent almost an hour to find out what the problem is. This might be useful to someone who faces the same problem and saves some time.

Actual problem was in folder path. I am using MacOs and folder name like ProjectA/ProjectB is absolutely valid in MacOs. This folder name transforms in terminal into something like this: ~/gitHub/ProjectA:ProjectB/ProjectA/src. And from terminal point of view this is also absolutely valid path, you can cd there and list files, everything is working, but Gradle does not like it, when you execute command with gradle wrapper it returns an error from the question above. It was not a good idea to name folder like this, but gradle might have better error returned or even handle such case, but probably this is just a generic java limitation.

  • Related