All Products
Search
Document Center

Artificial Intelligence Recommendation:SDK for Java

Last Updated:Sep 06, 2023

Download link

Artificial Intelligence Recommendation (AIRec) SDK for Java allows Java developers to use the Java program to manage the AIRec service. You can add the SDK as a dependency to your Maven project. You can also download the installation package to an on-premises directory. The SDK for Java supports Java 2 Platform, Standard Edition (J2SE) 6.0 and later.

You can click here to download AIRec SDK for Java of the latest version. You can click here to view the source code of AIRec SDK for Java of the latest version.

Procedure

To use AIRec SDK for Java, perform the following steps:

Step 1: Create an Alibaba Cloud account

For more information, see Sign up with Alibaba Cloud. We recommend that you complete real-name verification at your earliest opportunity. Otherwise, you cannot use some Alibaba Cloud services.

Step 2: Obtain an Alibaba Cloud AccessKey pair

Before you use AIRec SDK for Java, you must apply for an Alibaba Cloud AccessKey pair.

Go to the AccessKey Pair page. Select an AccessKey pair for AIRec SDK for Java. If no AccessKey pair is available, create one and make sure that it is in the enabled state. For more information about how to create an AccessKey pair, see Create an AccessKey pair.

Step 3: Install a Java development environment

AIRec SDK for Java supports Java development environments of J2SE 6.0 or later. You can visit the Java official website to download and install a Java development environment.

Step 4: Install the SDK for Java

We recommend that you download the latest SDK for Java package by using Apache Maven. You can add the following dependencies to your Maven project. aliyun-java-sdk-core is the core library. We recommend that you use aliyun-java-sdk-core 4.2.2 or later. aliyun-java-sdk-core uses Gson 2.8.2 as a dependency. We recommend that you manually configure the Gson dependency. If you have used Gson of a version earlier than 2.8.2 in your business, we recommend that you update your Gson to 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: Use AIRec SDK for Java

In the following example, the DescribeInstance operation is used to describe how to use AIRec SDK for Java. The DescribeInstance operation is used to query the information about an instance. The IClientProfile and IAcsClient classes are contained in the aliyun-java-sdk-core library, and other classes are contained in the aliyun-java-sdk-airec library.

Push data and obtain recommendation results

For more information about the sample code used to push data, see Push data.

For more information about the sample code used to obtain recommendation results, see Obtain recommendation results.