This topic describes how to install the Alibaba Cloud SDK for Java by using Maven dependencies.

Prerequisites

Java Development Kit (JDK) 1.8 or later is installed and environment variables are configured.

You can run the java -version command to check the Java version.

Procedure

  1. Download Maven.
    Visit the Apache Maven download page and download the required Maven package based on your operating system. You can use the checksum file to check whether the downloaded file is valid. The figures shown in this topic are captured on the Windows 7 64-bit operating system and in Eclipse Luna.Environment
  2. Visit the Alibaba Cloud SDK for Java download page and download the aliyun-java-sdk-core library to be imported to Maven.
    If you cannot find the SDK for your service, visit the Java SDK download page for more services and search for the required SDK. You can also visit search.maven.org and search for the latest version of the required SDK.
  3. Find and decompress the downloaded Maven package. Add the following Maven repository information to the settings.xml file in the conf directory.
    <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>
  4. Create a Maven project in one of the following methods:
    • Method 1: Create a Maven project in Eclipse.Create project
    • Method 2: Convert an existing project to a Maven project.Convert project
  5. Open the pom.xml file of the Maven project and add the dependency on aliyun-java-sdk-core to the file.
     <dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-core</artifactId>
      <version>4.0.3</version>
    </dependency>
  6. Add the dependency on aliyun-java-sdk-dataworks-public to the pom.xml file.
     <dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-dataworks-public</artifactId>
      <version>2.2.4</version>
    </dependency>
  7. Save the changes.
    The system automatically downloads the JAR packages specified in Maven dependencies and adds them to the Maven project.SDK