0

I am trying to call a method, but I keep getting the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/text/StringEscapeUtils

From what I understood I was supposed to have this dependency in my build.gradle file:

dependecies {
    ...

    compile group: 'org.apache.commons', name: 'commons-text', version: '1.6'
    ...
}

I did that, but I keep getting the abovementioned error. I also tried the v1.9 of org.apache.commons-commons-text dependency as well, again with the same results.

Is there something else I am missing?

I also tried to do what was answered in this question but it does not seem to work.

Abra
  • 19,142
  • 7
  • 29
  • 41
csymvoul
  • 677
  • 3
  • 15
  • 30
  • The answer you linked to is about `ClassNotFoundException`. That is not the same as [NoClassDefFoundError](https://docs.oracle.com/javase/8/docs/api/java/lang/NoClassDefFoundError.html). Your code compiles because Apache Commons is in your build path but your code fails at runtime because the runtime class path (or module path) does not include Apache Commons. I don't know [gradle](https://gradle.org/) so I can't tell you how to fix it. – Abra Dec 13 '20 at 08:22
  • Do you know how to make it work in another type of project (e.g. maven)? maybe this would help – csymvoul Dec 14 '20 at 12:06
  • Don't use Maven either. Refer to the [java command documentation](https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE) – Abra Dec 14 '20 at 16:04

0 Answers0