java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

We Are Going To Discuss About java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7. So lets Start this Java Article.

java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

  1. java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

    If you use Gradle Wrapper then refer to $PROJECT_ROOT/gradle/wrapper/gradle-wrapper.properties. The property distributionUrl should be:
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
    If it's an older version then change it, run ./gradlew clean build and try again.

  2. Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

    If you use Gradle Wrapper then refer to $PROJECT_ROOT/gradle/wrapper/gradle-wrapper.properties. The property distributionUrl should be:
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
    If it's an older version then change it, run ./gradlew clean build and try again.

Solution 1

How do you run the application? It’s probably because you use Gradle as the build system and JDK14 and the Gradle version is old.
Reference: https://github.com/gradle/gradle/issues/10248

If you use Gradle Wrapper then refer to $PROJECT_ROOT/gradle/wrapper/gradle-wrapper.properties. The property distributionUrl should be:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip

If it’s an older version then change it, run ./gradlew clean build and try again.

Original Author Of This Content

Solution 2

I solved it by editing the gradle-wrapper.properties file inside the gradle folder. (Not .gradle) :

Change this line, from:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip

to:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

rebuild and it’s ok.

Original Author Of This Content

Solution 3

In the file android/gradle/wrapper/gradle-wrapper.properties, ensure that the distributionUrl is as follows:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip

Note: If you installed jdk 14

Original Author Of This Content

Solution 4

Got the same issue on a Maven & SpringBoot project, no Gradle whatever.

The dependency to org.codehaus.groovy is probably transitive through spring-cloud-contract-verifier. Run mvn dependency:tree to view the whole dependency tree.

I got it fixed by upgrading the spring-cloud-contract-maven-plugin version to 2.2.3-RELEASE

Original Author Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment