This topic describes how to install Content Moderation SDK for Java. aliyun-java-sdk-green 3.6.6 is used as an example.
Prerequisites
This environment requires Java 1.6 or later.
You can run the java -version command to check the Java version.
Install the SDK
To use aliyun-java-sdk-green in a Maven project, add the required dependencies to the pom.xml file. For version 3.6.6, add the following content to the <dependencies> block:
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-green</artifactId>
<version>3.6.6</version>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>2.8.3</version>
</dependency>Part of the Java sample code is compiled based on Java dependencies to read files and convert strings. You can add the following content to <dependencies> as required:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>If you want to submit a local or binary file for content moderation, download and import the Extension.Uploader utility class into your project.
Configure environment variables
Alibaba Cloud SDKs create default credentials by reading the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables. When you call an API operation, the program reads your AccessKey from these variables and automatically completes authentication. Before you use SDK sample code, you must configure the environment variables. For more information, see Configure authentication credentials.