This topic describes how to install Resource Management SDK for Java and provides an example on how to use Resource Management SDK for Java.

Background information

  • To use Resource Management SDK for Java, you must install both the core library of Alibaba Cloud SDK for Java (aliyun-java-sdk-core) and Resource Management SDK for Java (aliyun-java-sdk-resourcemanager).
  • Alibaba Cloud provides OpenAPI Explorer to simplify API usage. You can use OpenAPI Explorer to debug API operations and dynamically generate SDK sample code.
  • For more information about Resource Management API operations, see List of operations by function.

Install the SDK for Java

You can use one of the following methods to install the SDK for Java:

  • Method 1: Add dependencies by using Maven (recommended)
    1. Use Maven to create a project.
      mvn archetype:generate -DgroupId=com.aliyun.resourcemanager.sample \
      -DartifactId=resourcemanager-sdk-sample \
      -Dpackage=com.aliyun.resourcemanager.sample \
    2. Add the following dependencies to the pom.xml file of the project:
      Note Visit the Maven repository to obtain the aliyun-java-sdk-core and aliyun-java-sdk-resourcemanager packages of the latest version.
  • Method 2: Download the JAR packages of the SDKs and add the packages to your project

    You can use this method to install the SDKs for Java regardless of whether you are using Eclipse or IntelliJ as the integrated development environment (IDE). You can download the JAR packages of the SDKs from the following links:


The following sample code provides an example on how to call the CreateResourceAccount operation by using the SDK for Java. For other operations, you can use OpenAPI Explorer to debug the operations and obtain sample code.

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import java.util.*;
import com.aliyuncs.resourcemanager.model.v20200331.*;
public class CreateResourceAccount {
    public static void main(String[] args) {
        // Construct an Alibaba Cloud client to initiate requests. 
        // When you construct the client, specify your AccessKey ID and AccessKey secret. 
        DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "<accessKeyId>", "<accessKeySecret>");
        IAcsClient client = new DefaultAcsClient(profile);
        // Construct a request. 
        CreateResourceAccountRequest request = new CreateResourceAccountRequest();
        // Specify request parameters. For more information about the parameters, see API Reference. 
        // Initiate the request and obtain a response. 
        try {
            CreateResourceAccountResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch(ServerException e) {
        } catch(ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
Note The content that is enclosed by angle brackets (<>) in the sample code is for reference only. When you call the operation, replace the content with actual values and delete the angle brackets.