We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Java API: import com.constantcontact.ConstantContact cannot be resolved

Regular Participant

Java API: import com.constantcontact.ConstantContact cannot be resolved


I'm trying to get started with the Java API.

I downloaded the Java SDK.

I installed the Eclipse Maven Plugin and imported the files using the Maven POM file.


All of the files in src/main/java appear to validate fine.


When I try to write the example given in the readme file it doesn't recognize the ConstantContact library, giving the error message: The import com.constantcontact.ConstantContact cannot be resolved.


I added a new package at the end of the packages in the src/main/java folder, after com.constantcontact.webhooks.model package.  From there I added a new class with the following code:


package JGL;

import com.constantcontact.components.Component;

import com.constantcontact.ConstantContact;



public class Run {

public static void main(String[] args){

ConstantContact constantContact = new ConstantContact("api", "token");

Contact contact = constantContact.getContact(2);




Note that Eclipse does recognise the components.Component library. 


Any ideas on why I can't get this to work?





Regular Participant

It occured to me that since the other library imports fine, maybe the sdk has changed since the original readme post.  I dug into the code and got this to work:


import com.constantcontact.components.contacts.Contact;

import com.constantcontact.exceptions.service.ConstantContactServiceException;



public class Run2 {

public static void main(String[] args){

String api = "api";

String token = "token";


ContactService cs = new ContactService(token,api);


Contact c = new Contact();


c =cs.getContact("2");


catch(ConstantContactServiceException ccse) {





Must be the that the original examples no longer work.






My apologies for the delayed response! What you observed about changes in the SDK is correct! There was a major update to the SDK that was designed to move towards a proper service based SDK, rather than relying on a very large and difficult to read master class. The sample code included with the SDK on our github repo has also been updated and can be used as a reference if needed.


If you have any questions about using the updated SDK, please feel free to ask!



Elijah G.
API Support Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page