All Products
Search
Document Center

Key Management Service:Install Alibaba Cloud SDK (Java)

Last Updated:Jun 03, 2025

This topic describes how to install Alibaba Cloud SDK for Java.

Alibaba Cloud SDK supports both management operations (such as creating instances and keys) and business operations (such as encryption, decryption, and secrets retrieval) through OpenAPI calls. Management operations are accessible through the shared gateway, while business operations can be performed through both the shared and dedicated gateways.

Before using Alibaba Cloud SDK, familiarize yourself with its usage notes, such as workflow, the differences of gateways accessed, and supported APIs, to ensure a smooth integration with KMS. For more information, see Alibaba Cloud SDK.

Prerequisites

  • A KMS instance is purchased and enabled. For more information, see Purchase and enable a KMS instance.

  • A key or secret is created based on your business needs. For more information, see Software-protected keys, Hardware-protected keys, and Create a secret.

  • If your business is deployed outside Alibaba Cloud VPC, you must enable public network access for business operations through the shared gateway. For instructions, see Access keys in a KMS instance through the public network.

    If you are only performing management operations through the shared gateway, you do not need to enable public network access.

  • For businesses deployed within Alibaba Cloud VPC, perform operations through the dedicated gateway and ensure that your applications can access the KMS instance VPC address <YOUR_KMS_INSTANCE_ID>.cryptoservice.kms.aliyuncs.com.

    • If the application and the KMS instance are in the same region and VPC, the network is interconnected by default.

    • If the business application and the KMS instance are in the same region but different VPCs, you must associate the VPC with the KMS instance. For instructions, see Access KMS instances in multiple VPCs in the same region.

Environment requirements

Java 8 or a later version must be downloaded and installed.

To check the Java (JDK) version, launch the terminal and enter java -version.

Install SDK

To install Alibaba Cloud SDK, add a Maven dependency to your project. The Java package will then be automatically downloaded from the Maven repository.

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>kms20160120</artifactId>
  <version>1.2.3</version>
</dependency>
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>tea</artifactId>
    <version>1.3.2</version>
</dependency>
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>tea-openapi</artifactId>
    <version>0.3.6</version>
</dependency>
Important

We recommend using the latest version. For information on versions and source code, see kms-20160120.