This topic describes how to configure the required dependencies and environment for SDKs for Java.

Prerequisites

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

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

Procedure

  1. Download a Maven installation package.
    Visit the Maven download page and download the required Maven installation 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 the Eclipse Luna environment.Environment
  2. Visit theAlibaba Cloud SDK for Java download page, and download the aliyun-java-sdk-core library to be imported to Maven.
    If you cannot find the required SDK, visit the SDK for Java download page for more services and search for the required SDK. You can also visit the search.maven.org website and search for the latest version of the required SDK.
  3. Find and decompress the downloaded Maven installation package. Add the following Maven repository 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>
  4. Create a Maven project by using one of the following methods:
    • Method 1: Create a Maven project in Eclipse.Create a project
    • Method 2: Convert an existing project to a Maven project.Convert a project
  5. Open the pom.xml file of the Maven project and add aliyun-java-sdk-core to the file.
     <dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-core</artifactId>
      <version>4.5.1</version>
    </dependency>
  6. Open the pom.xml file of the Maven project and add aliyun-java-sdk-dataworks-public to the file.
    <dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-dataworks-public</artifactId>
      <version>3.2.3</version>
    </dependency>
  7. Save the changes.
    The JAR packages that are specified in Maven dependencies are automatically downloaded and added to the Maven project.SDK