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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3468027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 01:02:22  来源:igfitidea点击:

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

java

提问by LGAP

Why does the following happen 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.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

采纳答案by BalusC

This means that the class org.apache.commons.lang.Validateis missing in the runtime classpath. You just have to add the JAR file containing the class to the runtime classpath. It's the Apache Commons Lang JAR file. This is also explicitly mentioned at the current Jsoup download page.

这意味着org.apache.commons.lang.Validate运行时类路径中缺少该类。您只需将包含该类的 JAR 文件添加到运行时类路径。它是Apache Commons Lang JAR 文件。在当前的 Jsoup 下载页面中也明确提到了这一点。

Assuming that you're launching it using plain vanilla java.exelike as in your previous question, then do so:

假设您java.exe像在上一个问题中一样使用普通香草启动它,然后执行以下操作:

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


Note that the Jsoup author has mentionedto remove the Commons Lang dependency in the next Jsoup release.

请注意,Jsoup 作者已经提到在下一个 Jsoup 版本中删除 Commons Lang 依赖项。

The next release of jsoup will not require Apache Commons-Lang or any other external dependencies, which brings down the jar size to around 115K.

下一版本的 jsoup 将不需要 Apache Commons-Lang 或任何其他外部依赖项,这将 jar 大小降低到 115K 左右。

Jsoup 1.3.1 is the first version which does not require Apache Commons Lang anymore.

Jsoup 1.3.1 是第一个不再需要 Apache Commons Lang 的版本。

回答by polygenelubricants

You need to download the Apache Commons/Langand make sure it's included in CLASSPATH(or if using IDE, make sure that all required libraries are included in the build configuration).

您需要下载Apache Commons/Lang并确保它包含在CLASSPATH(或者如果使用 IDE,请确保所有必需的库都包含在构建配置中)。

See also

也可以看看

回答by Kingo

Looks like you need the jar file in your classpath. From google it could be commons-lang-2.4.jar or similar

看起来您需要类路径中的 jar 文件。从谷歌它可能是 commons-lang-2.4.jar 或类似的