Search code examples
javagradleclassnotfoundexception

How to resolve java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain error?


we are trying to deploy code to a FRC robot with VScode, but we keep getting the error:

Error: Could not find or load main class
org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException:
org.gradle.wrapper.GradleWrapperMain
The terminal process terminated with exit code: 1

we have found that other people have also gotten similar errors, but none of their solutions have helped us. We would really appreciate any help resolving this error Thanks


Solution

  • I assume you are using the Gradle wrapper script (gradlew on the command line). This script relies on two other files:

    gradle/wrapper/gradle-wrapper.jar
    gradle/wrapper/gradle-wrapper.properties
    

    My guess is that the jar file is missing or corrupt. You can try regenerating them by downloading Gradle manually and then running gradle wrapper (note the missing 'w') in the same folder. If this is code you are maintaining in a version control repository (e.g. Git), make sure to add and commit these two files to the repository.