Java: Try Me First
First thing you'll want to do is edit the file pmjava/postalmethods.properties and update the username and password values to match your account username and password.
The Java code we will be running is FirstLetter.java. This code sample will send a sample PDF letter using the PostalMethods API. To compile and run it do the following:
% set PM_HOME=<path to pmjava directory> % run.bat
% export PM_HOME=<path to pmjava directory> % ./run.sh
This command will compile and run the FirstLetter.java program and the output will look something like this:
PM_HOME is <path to pmjava directory> Building FirstLetter.java ... FirstLetter.java 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: ResultCode: 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.