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

Occasional Contributor

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?





Occasional Contributor

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

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.




Honored Contributor

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



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

Register for our "Making Sense of Online Marketing for Retail" Webinar

Aug 13 retail why ctct banner.png

Join us on Thursday, August 13th at 2pm ET for a free webinar where we'll discuss how to incorporate online marketing into your retail store.


Online marketing presents opportunities for retail stores to get found, get more sales, and ultimately grow the business.


If you’re just getting started with online marketing or not seeing the results you’ve hoped for then this session is for you. With our guest expert, Bryan Caplan, you’ll learn a smarter, more practical approach to getting the word out about your retail store. From making sure your business is found to keeping it top of mind, find out how to get the word out to the people who matter most online.


Read More