Running your Java sample programs from a command line

To run one of the Java sample programs from a command line, enter the Java -classpath command from the /Sample_Source directory.

The class path statement defines a search path to the directory where the JAR file is stored that holds the Adobe PDF Library Java sample program files. The command statement provides the name of this JAR file and the name of the sample program you want to run, and any optional Java program arguments available with that sample program.

Use this command syntax:

java -Djava.library.path=target/lib -cp target/maven-samples<version>.jar <main-class-name> <args>

For example, your command might look like this, to run the TextExtract sample program:

java -Djava.library.path=target/lib -cp target/maven-samples-15.7.37.jar com.datalogics.pdfl.samples.Text.TextExtract.TextExtract

or this, to run AddElements:

java -Djava.library.path=target/lib -cp target/maven-samples-15.7.37.jar com.datalogics.pdfl.samples.ContentCreation.AddElements.AddElements

The sample program name includes the name of the main class.

Enter arguments for a sample program as parameters on the command line. For example, for the sample, you can enter the file name of your own PDF input document as a command line parameter.