edit-icon download-icon

JAVA SDK

Last Updated: Jan 09, 2018

You can write codes based on Alibaba Cloud SDK to call an Alibaba Cloud API so as to flexibly deploy and quickly operate Alibaba Cloud products and services.

Note: AccessKey is needed in the using process. You can create and manage the AccessKey on the AccessKey Management page.

Prerequisites

You can query and download the latest SDK at https://oss.sonatype.org/#nexus-search;gav~com.aliyun~aliyun-java-sdk-*~~~.

You can download the source codes from GitHub.

Maven

  1. <repositories>
  2. <repository>
  3. <id>sonatype-nexus-staging</id>
  4. <name>Sonatype Nexus Staging</name>
  5. <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
  6. <releases>
  7. <enabled>true</enabled>
  8. </releases>
  9. <snapshots>
  10. <enabled>true</enabled>
  11. </snapshots>
  12. </repository>
  13. </repositories>
  14. <dependencies>
  15. <dependency>
  16. <groupId>com.aliyun</groupId>
  17. <artifactId>aliyun-java-sdk-core</artifactId>
  18. <version>2.3.3</version>
  19. </dependency>
  20. <dependency>
  21. <groupId>com.aliyun</groupId>
  22. <artifactId>aliyun-java-sdk-cs</artifactId>
  23. <version>2.0.2</version>
  24. </dependency>
  25. </dependencies>

Sample

  1. public static void main(String[] argc) throws Exception {
  2. String accessKeyID = "xx";
  3. String accessKeySecret = "xx";
  4. String region="cn-shenzhen"; // or other
  5. DescribeApiVersionRequest describeApiVersionRequest = new DescribeApiVersionRequest();
  6. IClientProfile profile = DefaultProfile.getProfile(region, accessKeyID, accessKeySecret);
  7. IAcsClient client = new DefaultAcsClient(profile);
  8. try {
  9. HttpResponse httpResponse
  10. = client.doAction(describeApiVersionRequest);
  11. System.out.println(httpResponse.getUrl());
  12. System.out.println(new String(httpResponse.getContent()));
  13. } catch (ClientException e) {
  14. e.printStackTrace();
  15. }
  16. }
Thank you! We've received your feedback.