Java: Try Me First

Download our Java samples from this page.
Find a ready-to-run code sample that is a good starting point for accessing the PostalMethods API via Java in the pmjava/firstLetter folder.

First thing you'll want to do is edit the file pmjava/ and update the username and password values to match your account username and password.

The Java code we will be running is This code sample will send a sample PDF letter using the PostalMethods API. To compile and run it do the following:

On Windows:

% set PM_HOME=<path to pmjava directory>
% run.bat

On Linux/Unix:

% export PM_HOME=<path to pmjava directory>
% ./

This command will compile and run the program and the output will look something like this:

PM_HOME is <path to pmjava directory>
Building ... has been built.
Running the FirstLetter program ...
File to send: <path to pmjava directory>/misc/sample-letter.pdf
Making call to SendLetter...
Service call completed:
       code: 1022100
    message: Letter has been successfully received.
description: Letter has been received and is being processed. The numeric code returned by this call is your letter id.
FirstLetter program has run.

Congratulations! You've sent your first letter using the PostalMethods API.