Download
The AIRec Java SDK allows Java developers to interact with the AIRec service using Java programs. You can add the SDK using Maven dependencies or by downloading the package to your local machine. The SDK supports J2SE 6.0 and later.
Click here to obtain the latest version of the SDK. Click here to view the source code of the latest SDK.
Steps
Follow these steps to get started with the AIRec Java SDK.
Step 1. Create an Alibaba Cloud account
For more information, see the Alibaba Cloud account registration process. To use all Alibaba Cloud services, you must complete identity verification. Some Alibaba Cloud services are unavailable until you complete this verification.
Step 2. Obtain an Alibaba Cloud AccessKey
You need an Alibaba Cloud AccessKey to use the AIRec Java SDK.
Log on to the Alibaba Cloud Key Management page. Select an AccessKey pair for the SDK. If you do not have an AccessKey pair, create one. Make sure the key pair is Enabled. For more information about how to create an AccessKey, see Create an AccessKey.
Step 3. Install the Java development environment
The AIRec Java SDK requires J2SE 6.0 or later. You can download and install the Java development environment from the official Java website.
Step 4. Install the Java SDK
You can use Apache Maven to obtain the latest version of the SDK. Add the following configuration to your Maven project. The `aliyun-java-sdk-core` is the core library, and you must use version 4.2.2 or later. Because `aliyun-java-sdk-core` depends on gson version 2.8.2, you must add the gson dependency manually. If your project uses an earlier version of gson, you must upgrade it to version 2.8.2 or later.
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-airec</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>Step 5. Start using the SDK
This section uses the Query instance information method as an example to demonstrate the complete process of using the SDK. The `IClientProfile` and `IAcsClient` classes are in the `aliyun-java-sdk-core` folder. The other classes are in the `aliyun-java-sdk-airec` folder.
Push data and get recommendation results
For sample code and more details about how to push data, see Push data.
For sample code and more details about how to obtain recommendation results, see Get recommendation results.