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
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.Assuming that you’re launching it using plain vanilla
java.exelike as in your previous question, then do so:Note that the Jsoup author has mentioned to remove the Commons Lang dependency in the next Jsoup release.
Jsoup 1.3.1 is the first version which does not require Apache Commons Lang anymore.