The Adobe PDF Library Java samples are distributed together as a Maven project. Maven is an open source software management tool provided by the Apache Software Foundation that can automate the software build process. An XML file provided for each product describes how the software is built, including conventions, dependencies on external software modules, components, and plug-ins, and the build order. Maven also allows you to generate reports. We provide a utility with the Java Maven project that finds and runs Maven for you, so that you don’t need to install Maven locally if you don’t have it in place already. Under the /Java directory you will see the Maven script file, mvnw.cmd for Windows and mvnw for Linux.
You can import the Adobe PDF Library Java Maven project easily into your local Integrated Development Environment (IDE) tool, like Eclipse or IntelliJ.
Note that a minimum requirement is to have Java Development Kit 7 (JDK 7) installed. The Maven build will also work with Java SE 9.
Install the Maven artifacts
The first step is to add a set of artifacts specific to Adobe PDF Library into the Maven repository on your local machine. In Maven, an artifact is a file that is stored in a repository to be used in a project. The artifacts Datalogics provides include a pair of Adobe PDF Library JAR files for the Java sample files, each one starting with “pdfl” and the software version (such as “pdfl-18.0.0.jar”). One is labeled “Javadoc.” The artifacts also include several zip files that include resources and binary files.
- The Maven repository is stored in your Windows user home directory, in a folder called /.m2. Your directory should look something like this:
If you install Maven on your local machine, the installation process will build a repository for you and create an /.m2 Maven repository folder in your user home directory. But you don’t need to install Maven. We provide an installation step that will create the /.m2 folder and the Maven repository for you, if the /.m2 folder is not already in place on your machine.
- Set the JAVA_HOME path by entering a set command at a command line prompt:
set JAVA_HOME=C:\Program Files\Java\jdk-9.0.4
Note also that most web sites no longer support version 1.0 of the Transport Layer Security (TLS) cryptographic protocol for securing web communications. But TLS 1.0 is the default for Java 7, so to use Java 7 you need to change the settings to default to TLS 1.2 or later. This will allow you to avoid protocol errors when Maven is running.
- Then, move to the Java directory in your Adobe PDF Library installation package. That will vary depending on where you install the software, and what version you are working with, but the directory will probably look something like this:
- Next, find the folder under /Java where the mvnw or mvnw.cmd and create-artifacts.xml files are stored.
- Run this command:
mvnw -f create-artifacts.xml install
or this command for Mac or Linux:
./mvnw -f create-artifacts.xml install
Build the Maven package
Switch to the /Sample_Source directory under the Java directory and run the package command, to package the samples:
The package process in Maven compiles the code related to a project and creates a file for storing it. For Adobe PDF Library, the Maven package is a JAR file. When you run the package command it will create a new directory under Sample_Source called /target, and store the JAR file in that directory structure. The JAR file will be named to match the release version of the Adobe PDF Library you have installed. Your Maven package file might be named pdfl-18.0.0.jar.
Set the Environment Variables
These environment variables must be added in your operating system platform: