java.lang.NoClassDefFoundError:org / apache / commons / lang / Validate [英] java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate

查看:871
本文介绍了java.lang.NoClassDefFoundError:org / apache / commons / lang / Validate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么会发生以下情况以及如何解决?

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$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


推荐答案

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

This means that the class org.apache.commons.lang.Validate is 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.

假设您使用普通的vanilla java.exe 与您的之前的问题一样,然后执行此操作:

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

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






请注意,Jsoup作者提及,以在下一个Jsoup版本中删除Commons Lang依赖。


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


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

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 1.3.1是第一个不再需要Apache Commons Lang的版本。

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

这篇关于java.lang.NoClassDefFoundError:org / apache / commons / lang / Validate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆