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?
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.
检查链接如何在堆栈溢出中将外部 jar 添加到类路径
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.