Amazon DynamoDB
Developer Guide (API Version 2012-08-10)

Running Java Examples for DynamoDB

General Process of Creating Java Code Examples (Using Eclipse)


Download and install the AWS Toolkit for Eclipse. This toolkit includes the AWS SDK for Java, along with preconfigured templates for building applications.


From the Eclipse menu, click File, New, Other...

In the Select a wizard box, click File, AWS Java Project, Click Next.

In the Project name field, type a name for your project. Click Finish to create the project. Note that the project is pre-configured, and includes the AWS SDK for Java .jar files.


You will now need to create a default credential profiles file. This file enhances security by storing your credentials separately from your project directories, so that they cannot be unintentionally committed to a public repository. For more information, see Using the Default Credential Provider Chain in the AWS SDK for Java Developer Guide.

The credential properties file should be saved as ~/.aws/credentials, where the tilde character represents your home directory. In this file, you can store multiple sets of credentials from any number of accounts. Each set is referred to as a profile. The following is an example of a credential properties file with a profile named default:

aws_access_key_id = <Your Access Key ID>
aws_secret_access_key = <Your Secret Key>

The code examples in this document use the default client constructors that read your AWS credentials stored in the credential properties file.


Copy the code from the section that you are reading to your project.


Run the code.

Setting the Region

You can set the DynamoDB region explicitly, as shown in the following Java code snippet.

client = new AmazonDynamoDBClient(credentials);

For a current list of supported regions and endpoints, see Regions and Endpoints.