All Products
Search
Document Center

E-MapReduce:Initialize a client

Last Updated:Sep 21, 2023

This topic describes how to use E-MapReduce (EMR) SDK for Java to initialize a client.

Background information

Alibaba Cloud provides OpenAPI Explorer to simplify API usage. You can use OpenAPI Explorer to debug API operations and dynamically generate SDK sample code.

Before you get started

Integrate EMR OpenAPI SDK for Java into your Eclipse project.

  • Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are configured. For more information, see Configuration methods.

  • Create a Maven project and add Maven dependencies.

    <dependency>
              <groupId>com.aliyun</groupId>
              <artifactId>aliyun-java-sdk-core</artifactId>
              <version>3.5.0</version>
         </dependency>
         <dependency>
              <groupId>com.aliyun</groupId>
              <artifactId>aliyun-java-sdk-emr</artifactId>
              <version>3.1.0</version>
          </dependency>
  • Download the required JAR files. In this example, Eclipse is used.

    1. Download the SDK.

      For more information, see Download links.

    2. Copy the JAR files that you downloaded to your project folder.

    3. Right-click the name of your project in Eclipse and choose Properties > Java Build Path > Add JARs.

    4. Select the JAR files that you copied in Step 2.

Initialize a client

IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
DefaultAcsClient client = new DefaultAcsClient(profile);