Reputation: 461
Trying to implement pdfbox in eclipse but I'm getting this error when I run it.
>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
> at org.apache.pdfbox.pdfparser.BaseParser.<clinit>(BaseParser.java:68)
> at com.pdf.util.PDFTextParser.<init>(PDFTextParser.java:26)
> at com.pdf.util.PDFTextParser.main(PDFTextParser.java:77)
>Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
> 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
The program stops at this line of code:
parser = new PDFParser (new FileInputStream(file));
PDFParser comes from pdfbox.
I'm guessing there's something wrong with how I've attached the JAR files?
Upvotes: 2
Views: 1630
Reputation: 72884
PDFBox requires Commons Logging (see this dependencies page from the project's website). You need to reference that Jar in the classpath along with the PDFBox Jar. If you use a build tool like Maven, it should automatically download it for your project.
Upvotes: 2
Reputation: 1304
Check link how to add external jar to classpath in stack overflow
Upvotes: 0