Before you can use Log Service SDK for Java to call the API operations of Log Service, you must install Log Service SDK for Java. This topic describes how to install Log Service SDK for Java by using various methods. You can choose a method based on your business requirements.

Prerequisites

  • Log Service is activated. For more information, see Activate Log Service.
  • An AccessKey pair is created and obtained. For more information, see AccessKey pair.

    An Alibaba Cloud account has permissions to call all API operations. If you use the AccessKey pair of an Alibaba Cloud account, security risks may occur. We recommend that you create and use a RAM user to call API operations or perform routine O&M. Make sure that the RAM user is granted the permissions to perform operations on Log Service resources. For more information, see Grant permissions to a RAM user.

  • A Java development environment is installed.

    Log Service SDK for Java supports Java runtime environment (JRE) 6.0 or later. You can run the java -version command to check the version of your Java development environment. If no Java development environment is installed, you can download an installation package from the Java official website and 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: Add dependencies to your Maven project. This method is recommended.

    If you want to use Log Service SDK for Java in Maven, you need only to add the required dependencies to the pom.xml file. After you add the dependencies, Maven automatically downloads the required Java Archive (JAR) package. In this example, the dependency version 0.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, the dependency version 0.6.64 is used. To import the JAR package, perform the following steps:

    1. Download the 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 your IntelliJ IDEA project

    In this example, the dependency version 0.6.64 is used. To import the JAR package, perform the following steps:

    1. Download the Log Service SDK for Java package.
    2. Select your project in IntelliJ IDEA and choose File > Project Structure.
    3. On the left 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 you downloaded and click OK.

What to do next

Get started with Log Service SDK for Java