User guide
Before running any of the AWS SDK for Java samples, you will need to set your AWS credentials in the
environment or with the AWS CLI as specified in Set Up your AWS Credentials for Use with the SDK for
Java (p. 7). The samples use the default credential provider chain whenever possible, so by setting your
credentials this way, you can avoid the risky practice of inserting your AWS credentials in files within the
source code directory (where they may inadvertently be checked in and shared publicly).
To run a sample from the command line
1. Change to the directory containing the sample's code. For example, if you are in the root directory
of the AWS SDK download and want to run the AwsConsoleApp sample, you would type:
cd samples/AwsConsoleApp
2. Build and run the sample with Ant. The default build target performs both actions, so you can just
enter:
ant
The sample prints information to standard output—for example:
===========================================
Welcome to the AWS Java SDK!
===========================================
You have access to 4 Availability Zones.
You have 0 Amazon EC2 instance(s) running.
You have 13 Amazon SimpleDB domain(s) containing a total of 62 items.
You have 23 Amazon S3 bucket(s), containing 44 objects with a total size
of 154767691 bytes.
Building and Running the Samples using the
Eclipse IDE
If you use the AWS Toolkit for Eclipse, you can also start a new project in Eclipse based on the AWS
SDK for Java or add the SDK to an existing Java project.
Note
After installing the AWS Toolkit for Eclipse, we recommend configuring the Toolkit with your
security credentials.You can do this anytime by selecting Preferences from the Window menu
in Eclipse, and then selecting the AWS Toolkit section.
To run a sample using the AWS Toolkit for Eclipse
1. Open Eclipse.
Version v1.0.0
70
AWS SDK for Java Developer Guide
Building and Running the Samples using the Eclipse
IDE