Java.lang.NoClassDefFoundError: org / apache / commons / lang / Validate

Why is the following happening and how can I fix it?

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate
    at org.jsoup.DataUtil.load(DataUtil.java:47)
    at org.jsoup.Jsoup.parse(Jsoup.java:57)
    at linksfind.main(linksfind.java:12)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.Validate
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 3 more
+3
source share
4 answers

This means that the class is org.apache.commons.lang.Validatenot in the path of the execution path. You just need to add the JAR file containing the class to the execution class path. This is Apache Commons Lang JAR file . This is also explicitly mentioned on the current Jsoup download page.

Assuming you run it with simple vanilla java.exe, as in the previous question, do the following:

java -cp .;/path/to/jsoup.jar;/path/to/commons-lang.jar com.example.YourClass

Please note that the author of Jsoup has mentioned to remove Commons Lang dependency in the next release of Jsoup.

jsoup Apache Commons-Lang , 115K.

Jsoup 1.3.1 - , Apache Commons Lang.

+8
+2

, jar . Google commons-lang-2.4.jar

+1

Source: https://habr.com/ru/post/1759322/


All Articles