0

Dear members of support, I have cloned this repo https://github.com/BrentDouglas/pdfbox and after that made

cd examples

after that I run

mvn clean install

That command generates inside of the examples folder a folder target with a jar name pdfbox-examples-3.0.0-SNAPSHOT.jar. I am trying to run the main class of org.apache.pdfbox.examples.signature.CreateSignature using

java -cp target/pdfbox-examples-3.0.0-SNAPSHOT.jar org.apache.pdfbox.examples.signature.CreateSignature

But I get

Error: Could not find or load main class org.apache.pdfbox.examples.signature.CreateSignature

What is wrong with my command? Could you help me, please?

Juan
  • 2,073
  • 3
  • 22
  • 37
  • have a look at https://stackoverflow.com/questions/29920434/maven-adding-mainclass-in-pom-xml-with-the-right-folder-path – Vincent Passau Jun 18 '19 at 07:21
  • 1
    The jar is not correctly added to your classpath, so it can't find the main class. You do a `cd examples` and then refer to `examples/target/...` in your classpath? You sure this is correct? Shouldn't this be `target/...` as you are already in the examples dir? – TheWhiteRabbit Jun 18 '19 at 07:21
  • @TheWhiteRabbit sorry I fix my question. – Juan Jun 18 '19 at 07:41

1 Answers1

1

As already said in the comments you don't set up the classpath correctly. Since you are already in the examples directory it should be java -cp target/....

But your real problem is that you didn't put all the dependencies into the classpath. You can retrieve the complete classpath by running the following command in the examples directory:

mvn dependency:build-classpath

So your final command should look something like this on Unix:

java -cp <output of dependency plug-in>:pdfbox-examples-3.0.0-SNAPSHOT.jar org.apache.pdfbox.examples.signature.CreateSignature

Or on Windows:

java -cp <output of dependency plug-in>;pdfbox-examples-3.0.0-SNAPSHOT.jar org.apache.pdfbox.examples.signature.CreateSignature

By the way. I think you should use this repo as PDFBox has been migrated to the Apache Github organization.

stevecross
  • 5,588
  • 7
  • 47
  • 85