Greets,
I'm currently trying to read the text of a pdf document. After trying more then 15 different solutions, the code still throws this error when I run it with the command "java -jar pdfx.jar":
 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pdfbox/pdmodel/PDDocument
        at com.test.pdf.Main.main(Main.java:17)
  Caused by: java.lang.ClassNotFoundException:   org.apache.pdfbox.pdmodel.PDDocument
        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)
        ... 1 more
Main.java
package com.test.pdf;
import java.io.*;
import org.apache.pdfbox.pdmodel.*;
import org.apache.pdfbox.text.PDFTextStripper;
public class Main {
     public static void main(String[] args){
     PDDocument pd;
     BufferedWriter wr;
     try {
            File input = new File("C:/Users/Test/Desktop/check.pdf");
            File output = new File("C:/Users/Test/Desktop/Ergebnis.txt");
            pd = PDDocument.load(input);
            System.out.println(pd.getNumberOfPages());
            System.out.println(pd.isEncrypted());
            pd.save("Copy.pdf"); 
            PDFTextStripper stripper = new PDFTextStripper();
            stripper.setStartPage(1); 
            stripper.setEndPage(1);
            wr = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output)));
            stripper.writeText(pd, wr);
            if (pd != null) {
                pd.close();
            }
            wr.close();
     } catch (Exception e){
             e.printStackTrace();
            }
         }  
}
And the pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>PDFReader</groupId>
  <artifactId>PDFReader</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
          <archive>
            <manifest>
              <mainClass>com.test.pdf.Main</mainClass>
            </manifest>          
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>  
    <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency> 
      <groupId>org.apache.pdfbox</groupId> 
      <artifactId>pdfbox</artifactId> 
      <version>2.0.11</version> 
    </dependency> 
  </dependencies> 
</project>
The jars for PdfBox and common-logging are already added in the classpath. The Build runs normally without an error. The pdf file is located on my desktop where i move the jar after the build and run it with cmd.
 
     
     
    