title: How to use AWS SDK for java with maven?
body: <p>I want to fetch the messages in the SQS queue. I am using the maven for the first time. Here are the steps I have did so far.</p>
  
  <p><strong>1. Created maven project using this command:</strong></p>
  
  <pre><code>mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=aws-try -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  </code></pre>
  
  <p>The above command created a <strong>aws-try</strong> directory with src folder and pom.xml.</p>
  
  <p><strong>2. Added AWS-SDK dependency in pom.xml:</strong></p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
    &lt;artifactId&gt;aws-java-sdk&lt;/artifactId&gt;
    &lt;version&gt;1.11.78&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>3. Added the SQSTry.java file under src > main > java > com > mycompany > app > SQSTry.java</strong></p>
  
  <pre><code>package com.mycompany.app;
  
  import java.util.List;
  import java.util.Map.Entry;
  
  import com.amazonaws.AmazonClientException;
  import com.amazonaws.AmazonServiceException;
  import com.amazonaws.auth.AWSCredentials;
  import com.amazonaws.auth.profile.ProfileCredentialsProvider;
  import com.amazonaws.regions.Region;
  import com.amazonaws.regions.Regions;
  import com.amazonaws.services.sqs.AmazonSQS;
  import com.amazonaws.services.sqs.AmazonSQSClient;
  import com.amazonaws.services.sqs.model.CreateQueueRequest;
  import com.amazonaws.services.sqs.model.DeleteMessageRequest;
  import com.amazonaws.services.sqs.model.DeleteQueueRequest;
  import com.amazonaws.services.sqs.model.Message;
  import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
  import com.amazonaws.services.sqs.model.SendMessageRequest;
  
  
  public class SQSTry {
  
  public static void main (String args[]) {
  
  
  System.out.println("SQSTry");
  
          AWSCredentials credentials = null;
          try {
              credentials = new ProfileCredentialsProvider().getCredentials();
          } catch (Exception e) {
              throw new AmazonClientException(
                      "Cannot load the credentials from the credential profiles file. " +
                      "Please make sure that your credentials file is at the correct " +
                      "location (~/.aws/credentials), and is in valid format.",
                      e);
          }
  
          AmazonSQS sqs = new AmazonSQSClient(credentials);
          Region apNortheast1 = Region.getRegion(Regions.AP_NORTHEAST_1);
          sqs.setRegion(apNortheast1);
  
          System.out.println("===========================================");
          System.out.println("Getting Started with Amazon SQS");
          System.out.println("===========================================\n");
  
  
  
  }
  }
  </code></pre>
  
  <p><strong>4. Now package command</strong></p>
  
  <pre><code>mvn package
  </code></pre>
  
  <p>The above command was run against the pom.xml in the root of aws-try directory.</p>
  
  <p>This gives the following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/AmazonClientException
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
      at java.lang.Class.getMethod0(Class.java:2866)
      at java.lang.Class.getMethod(Class.java:1676)
      at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
      at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
  Caused by: java.lang.ClassNotFoundException: com.amazonaws.AmazonClientException
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      ... 6 more
  </code></pre>
  
  <p>I have added the dependency correctly. If you have noticed the above SQSTry.java file, the <strong>AWSCredentials</strong> was also a package from amazon, but id does not give any error.</p>
  
  <p>What am I missing ?</p>