Before you can use Log Service SDK for Java to perform the required operations on Log Service, you must install Log Service SDK for Java. This topic describes how to install Log Service SDK for Java in various scenarios. Install Log Service SDK for Java based on your business requirements.

Prerequisites

  • Log Service is activated. For more information, see Activate Log Service.
  • An AccessKey pair is created and obtained. An Alibaba Cloud account has permissions to call all API operations. Therefore, security risks may arise if you use the AccessKey pair of an Alibaba Cloud account. We recommend that you log on as a RAM user that has permissions to call API operations or perform routine O&M. For more information, see AccessKey pair.
  • A Java development environment is installed.

    Log Service SDK for Java supports the Java runtime environment of Java SE 6 or later. You can run the java -version command to check the version of your Java development environment. You can download the installation package from the Java official website, and then install the Java development environment.

Install Log Service SDK for Java

You can install Log Service SDK for Java by using one of the following methods:

  • Method 1: Recommended. Add dependencies to your Maven project.

    To use Log Service SDK for Java in Maven, you must add the required dependencies to the pom.xml file. After the dependencies are added, the Maven project management tool automatically downloads the corresponding JAR packages. In this example, Log Service SDK for Java V0.6.64 is used. Add the following content to <dependencies>:

    <dependency>
        <groupId>com.aliyun.openservices</groupId>
        <artifactId>aliyun-log</artifactId>
        <version>0.6.64</version>
    </dependency>
  • Method 2: Import a JAR package to your Eclipse project.

    In this example, Log Service SDK for Java V0.6.64 is used in this example. To import the JAR package, perform the following steps:

    1. Download Log Service SDK for Java package.
    2. Select your project in Eclipse and choose File > Properties.
    3. On the left side of the Properties dialog box, click Java Build Path.
    4. On the Libraries tab, click Add External JARs.
    5. Select the JAR package that you downloaded and click Open.
    6. Click Apply and Close.
  • Method 3: Import a JAR package to IntelliJ IDEA

    In this example, Log Service SDK for Java V0.6.64 is used. To import the JAR package, perform the following steps:

    1. Download Log Service SDK for Java package.
    2. In IntelliJ IDEA, select your project and choose File > Project Structure.
    3. On the right side of the Project Structure dialog box, click Modules.
    4. On the Dependencies tab, choose + > JARs or directories.
    5. In the Attach Files or Directories dialog box, select the JAR package that is downloaded and click OK.

What to do next

Get started with Log Service SDK for Java