code: public static void main(String[] args) throws Exception {
  
          System.out.println("===========================================");
          System.out.println("Welcome to the AWS Java SDK!");
          System.out.println("===========================================");
  
  
          /*
           * Amazon EC2
           *
           * The AWS EC2 client allows you to create, delete, and administer
           * instances programmatically.
           *
           * In this sample, we use an EC2 client to submit a Spot request,
           * wait for it to reach the active state, and then cancel and terminate
           * the associated instance.
           */
          try {
              // Setup the helper object that will perform all of the API calls.
              Requests requests = new Requests();
  
              // Submit all of the requests.
              requests.submitRequests();
  
              // Loop through all of the requests until all bids are in the active state
              // (or at least not in the open state).
              do
              {
                  // Sleep for 60 seconds.
                  Thread.sleep(SLEEP_CYCLE);
              } while (requests.areAnyOpen());
  
              // Cancel all requests and terminate all running instances.
              requests.cleanup();
  
          } catch (AmazonServiceException ase) {
              // Write out any exceptions that may have occurred.
              System.out.println("Caught Exception: " + ase.getMessage());
              System.out.println("Reponse Status Code: " + ase.getStatusCode());
              System.out.println("Error Code: " + ase.getErrorCode());
              System.out.println("Request ID: " + ase.getRequestId());
          }
      }
docs: /*
  Before running the code:
  Fill in your AWS access credentials in the provided credentials
  file template, and be sure to move the file to the default location
  (~/.aws/credentials) where the sample code will load the
  credentials from.
  https://console.aws.amazon.com/iam/home?#security_credential
  
  WARNING:
  To avoid accidental leakage of your credentials, DO NOT keep
  the credentials file in your source directory.