This topic describes how to install the ECS Java SDK and Alibaba Cloud SDK core library.

Prerequisites

JDK 1.6 is installed before you install the ECS Java SDK.

Background information

You can download aliyun-java-sdk-ecs or use the SDK through Maven coordinates.

In this example, the client uses the Windows 7 64-bit operating system and the environment installed for Java is Eclipse Luna.

Procedure

  1. Download the Maven software corresponding to the operating system from the official Maven website (Download Apache Maven).

    You can use the checksum file to verify whether the downloaded file is correct.

    Maven download page
  2. Find and decompress the Maven package. Add the following Maven library information to the settings.xml file in the conf folder.
    <repositories>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Sonatype Nexus Staging</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            <snapshots>
        </repository>
    </repositories>
  3. Log on to the Alibaba Cloud Developer Center (https://developer.aliyun.com/tools/sdk?#/java) and add the Maven library stored in the Alibaba Cloud SDK to the Maven software.
  4. Create a Maven project using either of the following methods:
    • Method 1: Add a Maven project in Eclipse.Add a Maven project
    • Method 2: Convert an existing project to a Maven project.Convert an existing project to a Maven project
  5. Add dependency to the Maven project using either of the following methods:
    • Method 1: Open the pom.xml file under the Maven project and add dependencies including aliyun-java-sdk-core, aliyun-java-sdk-ecs, and fastjson. You can add different dependencies as needed.
      <dependencies>
          <dependency>
              <groupId>com.aliyun</groupId>
              <artifactId>aliyun-java-sdk-core</artifactId>
              <version>4.4.3</version>
          </dependency>
          <dependency>
              <groupId>com.aliyun</groupId>
              <artifactId>aliyun-java-sdk-ecs</artifactId>
              <version>4.17.1</version>
          </dependency>
          <dependency>
              <groupId>com.alibaba</groupId>
              <artifactId>fastjson</artifactId>
              <version>1.2.60</version>
          </dependency>
      </dependencies>
    • Method 2: Add selected dependencies from the graphical user interface.Add selected dependencies from the graphical user interface
  6. Save the changes.

    The system automatically downloads and adds the .jar Java SDK to the Maven dependencies.

    Maven dependencies