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

前端 未结 4 1284
自闭症患者
自闭症患者 2021-01-14 02:43

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.         


        
4条回答
  •  攒了一身酷
    2021-01-14 03:07

    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.

    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
    

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

    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 is the first version which does not require Apache Commons Lang anymore.

提交回复
热议问题