简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM