c. In the bin folder of your working directory, create a AwsCredentials.properties file, as shown
in the following example:
#Insert your AWS Credentials from http://aws.amazon.com/security-credentials
secretKey=*** Your Account Secret Access Key***
accessKey=***Your Account Access Key ID***
d. Ensure that you can run the Java program compiler (javac) and the Java application launcher
(java) from your working directory.You can test by running the following commands:
javac -help
java -help
2. Put the code that you want to run in a .java file, and save the file in the src folder. To illustrate the
process, we use the code from Managing Security Groups Using AWS SDK for Java (p. 37) so that
the file in the src directory is CreateAndModifyClusterSecurityGroup.java.
3. Compile the code.
javac -cp sdk/lib/aws-java-sdk-1.3.18.jar -d bin src\CreateAndModifyCluster
SecurityGroup.java
If you are using a different version of the AWS SDK for Java, adjust the classpath (-cp) for your version.
4. Run the code. In the following command, line breaks are added for readability.
java -cp "bin;
sdk/lib/*;
sdk/third-party/commons-logging-1.1.1/*;
sdk/third-party/httpcomponents-client-4.1.1/*;
sdk/third-party/jackson-core-1.8/*"
CreateAndModifyClusterSecurityGroup
Change the class path separator as needed for your operating system. For example, for Windows, the
separator is ";" (as shown), and for Unix, it is ":". Other code examples may require more libraries than
are shown in this example, or the version of the AWS SDK you are working with may have different
third-party folder names. For these cases, adjust the classpath (-cp) as appropriate.
To run samples in this document, use a version of the AWS SDK that supports Amazon Redshift.To
get the latest version of the AWS SDK for Java, go to AWS SDK for Java.
Setting the Endpoint
By default, the AWS SDK for Java uses the endpoint https://redshift.us-east-1.amazonaws.com/.
You can set the endpoint explicitly with the client.setEndpoint method as shown in the following
Java code snippet.
client = new AmazonRedshiftClient(credentials);
client.setEndpoint("https://redshift.us-east-1.amazonaws.com/");
For a list of supported AWS regions where you can provision a cluster, go to the Regions and Endpoints
section in the Amazon Web Services Glossary.
API Version 2012-12-01
119
Amazon Redshift Management Guide
Setting the Endpoint