The Alibaba Cloud V1.0 SDK will soon enter the Basic Security Maintenance phase and is no longer recommended for use. It is suggested to use the V2.0 SDK instead.
If you have any problem while using Alibaba Cloud SDK for Java, please submit an issue.
Requirements
To use Alibaba Cloud SDK for Java, you must have an Alibaba Cloud account as well as an AccessKey ID and an AccessKey Secret. Create and view your AccessKey on the RAM console or contact your system administrator.
To use the Alibaba Cloud SDK for Java to access the APIs of a product, you must first activate the product on the Alibaba Cloud console if required.
The Alibaba Cloud Java SDK requires JDK 1.8 or later.
Installation
If you use Apache Maven to manage Java projects, you only need to add corresponding dependencies to the pom.xml files of the projects. You can view the Maven dependencies of different cloud products in Alibaba Cloud SDK Center.
You must install aliyun-java-sdk-core library no matter which product development kit you want to use. For example, to call the ECS SDK, you need to install aliyun-java-sdk-core library and aliyun-java-sdk-ecs library .
To use the Ecs SDK as an example, you only need to declare the following two dependencies in the pom.xml file.
If maven is not downloading jar packages from a central repository, you need to add these dependencies in the pom.xml file, or a NoClassDefFoundError exception will be reported
Troubleshoot Provide OpenAPI diagnosis service to help developers quickly locate and troubleshoot errors by using RequestID or error message, and provide solutions.
Quick Examples
The following code example shows how to use Alibaba Cloud SDK for Java :
package com.testprogram;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.ecs.model.v20140526.*;
publicclassMain {
publicstaticvoidmain(String[] args) {
// 1. Create and initialize a DefaultAcsClient instanceDefaultProfileprofile= DefaultProfile.getProfile(
"<your-region-id>", // The region ID"<your-access-key-id>", // The AccessKey ID of the RAM account"<your-access-key-secret>"); // The AccessKey Secret of the RAM accountIAcsClientclient=newDefaultAcsClient(profile);
// 2. Create an API request and set parametersDescribeInstancesRequestrequest=newDescribeInstancesRequest();
request.setPageSize(10);
// 3. Initiate the request and handle the response or exceptions
DescribeInstancesResponse response;
try {
response = client.getAcsResponse(request);
for (DescribeInstancesResponse.Instance instance:response.getInstances()) {
System.out.println(instance.getPublicIpAddress());
}
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}
For security reason, we don't recommend to hard code credentials information in source code. You should access
credentials from external configurations or environment variables.
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
FAQs
Aliyun Open API SDK for Java
Copyright (C) Alibaba Cloud Computing
All rights reserved.
版权所有 (C)阿里云计算有限公司
http://www.aliyun.com
We found that com.aliyun:aliyun-java-sdk-edas demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 0 open source maintainers collaborating on the project.
Package last updated on 13 Nov 2023
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.