| Now Available: AWS SDK for Java As of March 2010, this library has been deprecated and will no longer be updated. We recommend using the new AWS SDK for Java, where you'll continue to get new feature updates and bug fixes. To learn more about the AWS SDK for Java, and for support with migration, see http://aws.amazon.com/sdkforjava. |
About This Sample
- A Java sample to demonstrate creating a queue, sending messages, receiving messages, and deleting messages.
- Based on the 2008-01-01 API version.
Prerequisites
- You must have a valid Amazon Web Services developer account.
- You must be signed up to use Amazon SQS.
- You must install Java 1.6 or newer:
- Follow the instructions on the Sun Java web site to install the JDK 1.6 (for the instructions, see http://java.sun.com/javase/downloads/index.jsp).
- Set your JAVA_HOME environment variable to point to your JDK installation location.
- To verify you have the correct JDK installed, open a console window and type the following:
java -version
The response should be similar to the following:
java version "1.6.0_02" Java(TM) SE Runtime Environment, build 1.6.0_02-b06) Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode)
- You must install Ant.
- Follow the instructions on the Apache Ant web site to install Ant (for the instructions, see http://ant.apache.org/manual/index.html).
- Set your ANT_HOME environment variable to point to your Ant installation location.
- To verify you have the correct version of Ant installed, open a console window and type the following:
ant -version
The response should be similar to the following:
Apache Ant version 1.6.5 compiled on June 2 2005
Running the Sample
- Go to the
/SQSJavaSample/SQSSample/src/com/amazonaws/sqsdirectory of the sample code package and open the SampleDriver.java file in a text editor. - Locate the following two lines of code:
static public String awsAccessKeyId = ""; static public String awsSecretAccessKey = "";
- Insert your Access Key ID and Secret Access Key between the quotation marks, as in the following
example:
static public String awsAccessKeyId = "Your Access Key ID";
static public String awsSecretAccessKey = "Your Secret Access Key";
- Save the file.
- At a command prompt, go to the top directory of the sample (it contains build.xml file) and type the
following:
ant run
The example compiles and runs.