AWS SDK for Java version 2
Developer Guide

Using the SDK with Apache Maven

You can use Apache Maven to configure and build AWS SDK for Java projects or to build the SDK itself.


You must have Maven installed to use the guidance in this topic. If it isn't already installed, visit to download and install it.

Create a New Maven Package

To create a basic Maven package, open a terminal (command line) window and run the following.

mvn -B archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DgroupId=org.example.basicapp \ -DartifactId=myapp

Replace org.example.basicapp with the full package namespace of your application. Replace myapp with your project name (this becomes the name of the directory for your project).

By default, Maven creates a project template for you using the quickstart archetype. This creates a Java 1.5 project. You must update your application to Java 1.8 to be compatible with AWS SDK for Java 2.0. To update to Java 1.8, add the following to your pom.xml file.

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>

You can choose a particular archetype to use by adding the -DarchetypeArtifactId argument to the archetype:generate command. To skip step to update the pom.xml file, you can use the following archetype that creates a Java 1.8 project from the start.

mvn archetype:generate -B \ \ -DarchetypeArtifactId=java8-quickstart-archetype \ -DarchetypeVersion=1.0.0 \ -DgroupId=com.example \ -DartifactId=sdk-sandbox \ -Dversion=1.0 \ -Dpackage=com.example

There are more archetypes available. See Maven Archetypes for a list of archetypes packaged with Maven.


For much more information about creating and configuring Maven projects, see the Maven Getting Started Guide.

Configure the SDK as a Maven Dependency

To use the AWS SDK for Java in your project, you need to declare it as a dependency in your project's pom.xml file. You can import individual components or the entire SDK. We strongly recommend that you pull in only the components you need instead of the entire SDK.

Specifying Individual SDK Modules (Recommended)

To select individual SDK modules, use the AWS SDK for Java bill of materials (BOM) for Maven. This ensures that the modules you specify use the same version of the SDK, and that they're compatible with each other.

To use the BOM, add a <dependencyManagement> section to your application's pom.xml file. Add bom as a dependency and specify the version of the SDK to use. Find the latest version in the AWS SDK for Java 2.x Reference.

<dependencyManagement> <dependencies> <dependency> <groupId></groupId> <artifactId>bom</artifactId> <version>2.X.X</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>

To view the latest version of the AWS SDK for Java BOM that is available on Maven Central, see This page also shows the modules (dependencies) that are managed by the BOM that you can include within the <dependencies> section of your project's pom.xml file.

You can now select individual modules from the SDK that you use to your application. Because you already declared the SDK version in the BOM, you don't need to specify the version number for each component.

<dependencies> <dependency> <groupId></groupId> <artifactId>kinesis</artifactId> </dependency> <dependency> <groupId></groupId> <artifactId>dynamodb</artifactId> </dependency> </dependencies>

Importing All SDK Modules (Not Recommended)

To pull in the entire SDK as a dependency, don't use the BOM method. Simply declare it in your pom.xml as follows. Find the latest version in the AWS SDK for Java 2.x Reference.

<dependencies> <dependency> <groupId></groupId> <artifactId>aws-sdk-java</artifactId> <version>2.X.X</version> </dependency> </dependencies>

Build Your Project

Once you set up your project, you can build it using Maven's package command.

mvn package

This creates your .jar file in the target directory.