Search code examples
javaeclipseclasspathbuildpathhtml-parser

java.lang.NoClassDefFoundError: org/htmlparser/util/ParserException


I'm trying to make this http://htmlparser.sourceforge.net/ code run in eclipse. There instructions are simply "To use the library, you will need to add either the htmllexer.jar or htmlparser.jar to your classpath when compiling and running."

I've added htmllexer.jar and htmlparser.jar to my build path and everything compiles fine. But at runtime eclipse can't seem to find those jar files. I'm not sure how to add those jar files to the runtime classpath....

My eclipse looks like this: enter image description here


Solution

  • For a web project you have to drop those libraries straight in the /WEB-INF/lib folder of the project. This folder participates in webapp's default runtime classpath. In Eclipse, you don't need to fiddle with the build path properties this way, Eclipse will do all the necessary magic. Don't forget to undo the changes you made before.