Importing and running Java samples in IntelliJ

Import the Maven project

We also describe how to set up IntelliJ as your IDE to run Adobe PDF Library Java sample programs.

Open IntelliJ.

IntelliJ_01

Select Import Project.

Note that if you already have a project loaded in IntelliJ, your screens might look somewhat different from these shown here, but the steps will work the same way.

IntelliJ_02

Browse to the Java/Sample_Source directory for your Adobe PDF Library installation.

IntelliJ_03

Click OK.  Select the option to Import project from external model, and select Maven.

IntelliJ_04

Click Next.

IntelliJ_05

Don’t change the default values shown. Click Next.

Under Select Maven projects to import, click select the project and click Next.

Select the project SDK to use.  JDK v.1.7.0_80 is the minimum required version.  If the JDK you want to use does not appear, click the IntelliJ plus sign sign to add it. Click Next. Select the version of the JDK you have installed on your machine and that you plan to use with IntelliJ.

Generate the project sources

Right click on the project name. Click Maven and Generate Sources and Update Folders.

IntelliJ_07

Click the Target folder so that it appears with Sample_Source in the project view.

IntelliJ_08

Set the Run Configuration defaults

Click Run, and Edit Configurations.

IntelliJ_09

Expand the Defaults folder to display the list of default options.

IntelliJ_10

Click Application.

IntelliJ_11

Add this value as the VM options:

-Djava.library.path=target/lib

IntelliJ_12

Add the environment variables for your platform, Windows, UNIX, or Mac.  Click IntelliJ Add button next to the Environment variables field.

Click IntelliJ plus sign to add a new Environment variable.  You will add two environment variables for your platform:

Windows
DLE_INSTALL_LOCATION=target\lib
PATH=target\lib

Unix
DLE_INSTALL_LOCATION=target/lib
LD_LIBRARY_PATH=target/lib

Mac
DLE_INSTALL_LOCATION=target/lib
DYLD_LIBRARY_PATH=target/lib

For Windows, the Environment Variables would look like this:

IntelliJ_14

Leading to a Configuration Screen that looks like this:

IntelliJ_15

Click Apply, and OK.

This is how the environment variables should appear on your IntelliJ Configuration screen:

Windows:

DLE_INSTALL_LOCATION=target\lib;PATH=target/lib

UNIX:

DLE_INSTALL_LOCATION=target\lib;LD_LIBRARY_PATH=target/lib

Mac:

DLE_INSTALL_LOCATION=target\lib;DYLD_LIBRARY_PATH=target/lib

Run your Java sample. The default configuration settings will be saved and used automatically for any Adobe PDF Library sample Java program you run in the future using IntelliJ. After these default values are in place, you only need to select the main class when selecting a Java sample to open and run.