I am getting a NoClassDefFoundError on the PDDocument class when trying to read a PDF file with PDFBox. Here is the error I am getting:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pdfbox/pdmodel/PDDocument
at readpdf.ReadPDF.main(ReadPDF.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.pdfbox.pdmodel.PDDocument
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
Here is the code that generates the error:
```
try (PDDocument document = PDDocument.load(new File(pdfFile))) {
PDFTextStripper textStripper = new PDFTextStripper();
// Get total page count of the PDF document
int numberOfPages = document.getNumberOfPages();
//set the first page to be extracted
textStripper.setStartPage(1);
// set the last page to be extracted
textStripper.setEndPage(numberOfPages);
String text = textStripper.getText(document);
System.out.println(text);
}
```
Here are my imports just in case they could be an issue:
```
import java.io.File;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
```
edit: Here is the command I use to run the program from the windows command window -> java -jar readPdf.jar pdfFile.pdf I added the following jar files as library files in Netbeans when I first started building the program, pdfbox-20.0.20.jar, fontbox-20.0.20.jar, and commons-logging-1.2.jar. I am not using Maven, still trying to learn how to use it. Netbeans version 11.0 Windows 10 Corretto OpenJDK 11.0.7