This article describes how to initialize IoT Platform SDK for Java and the device SDK for Java. You must prepare a Java development environment, download the SDK package, import a project, and then initialize the SDKs.

Procedure

  1. Download and decompress the SDK package iotx-api-demo.
    This package contains the device SDK for Java and IoT Platform SDK for Java.
  2. Import the decompressed SDK package to your Java development environment.
  3. In the pom file in the java directory, add the following dependencies to import IoT Platform SDK for Java and the device SDK for Java.
    <! -- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-iot -->
    <dependency>
        <groupId>com.aliyun</groupId>
        <artifactId>aliyun-java-sdk-iot</artifactId>
        <version>6.5.0</version>
    </dependency>
    <dependency>
        <groupId>com.aliyun</groupId>
        <artifactId>aliyun-java-sdk-core</artifactId>
        <version>3.5.1</version>
    </dependency>
    <dependency>
      <groupId>com.aliyun.alink.linksdk</groupId>
      <artifactId>iot-linkkit-java</artifactId>
      <version>1.2.0.1</version>
      <scope>compile</scope>
    </dependency>
  4. In the config file in the java/src/main/resources/ directory, enter the required information for initialization.
    user.accessKeyID = <your accessKey ID>
    user.accessKeySecret = <your accessKey Secret>
    iot.regionId = <regionId>
    iot.productCode = Iot
    iot.domain = iot.<regionId>.aliyuncs.com
    iot.version = 2018-01-20
    Parameter Description
    accessKeyID The AccessKey ID of your Alibaba Cloud account.

    Place the pointer on your profile icon in the console, select AccessKey to go to the User Management page. You can create or check your AccessKey in User Management.

    accessKeySecret The AccessKey Secret of your Alibaba Cloud account. You can check the AccessKey Secret in the same way as the AccessKey ID.
    regionId The ID of the region where your IoT devices are located. For more information about region ID expressions, see Regions and zones.

What to do next

Connect the gateway to IoT Platform

Connect the sub-device to IoT Platform