Container Registry SDK for Java includes Alibaba Cloud SDK for Java, which is the common part, and the Container Registry part. The common part depends on aliyun-java-sdk-core. The Container Registry part depends on aliyun-java-sdk-cr. For more information about how to use each operation, see List of operations by function.


After you download the SDK, you can create a Maven project in your Maven repository and add Maven dependencies.

Sample code used to add Maven dependencies

<! -- Query the latest version number of the SDK from the repository.-->

API call example

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;

public class Sample {

    public static void main(String[] args) {

        try {
            // Configure the client.
            DefaultProfile.addEndpoint("cn-hanghzou", "cn-hangzhou", "cr", "");

            IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "AccessKeyId", "AccessKeySecret");

            DefaultAcsClient client = new DefaultAcsClient(profile);

            // Construct a request.
            GetImageLayerRequest request = new GetImageLayerRequest();

            // Set request parameters.

            // Initiate the request.
            HttpResponse response = client.doAction(request);

            // Process the response.
            System.out.println(new String(response.getHttpContent()));
        } catch (ClientException e) {
            System.out.println("code: " + e.getErrCode());
            System.out.println("message: " + e.getErrMsg());