Quick Start

Updated at:

This topic explains how to install Java and use the Java SDK.

Prerequisites

Requirements

Verify the version

Open a terminal and run java -version to check your Java (JDK) version.

Run the sample code

Step 1: Download the full SDK project

  1. Sign in to OpenAPI Explorer.

  2. In the top navigation bar, click Select Cloud Product. In the panel that appears, select a cloud product.

  3. Go to the product homepage. In the top navigation bar, click API Debugging to open a page with three panes.

  4. In the left pane, select an API operation. In the middle pane, enter the required parameters. In the right pane, select the SDK Sample tab.

  5. Set SDK Version to V2.0, and then select your preferred programming language.

  6. Click Download Full Project.

  7. To generate code for a generic call, select the Generate code in common mode checkbox. For more information, see Generic and typed calls.

Step 2: Configure environment variables

  1. Open a command-line terminal. Replace <ACCESS_KEY_ID> and <ACCESS_KEY_SECRET> in the following commands with your AccessKey ID and AccessKey Secret, and then run each command.

    export ALIBABA_CLOUD_ACCESS_KEY_ID=<ACCESS_KEY_ID>
    export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ACCESS_KEY_SECRET>
  2. Restart your IDE to ensure it reads the environment variables.

    Note

    On Linux, the preceding commands set a temporary environment variable that is valid only for the current terminal session. For example, you can package your application into a JAR file by running mvn package, and then run the JAR file from the same terminal session by running java -jar <jarfilepath>.

Step 3: Run the code

  1. Run the code in IntelliJ IDEA. Check the console log for the response body and the requestId.

  2. If you call an API operation that creates an instance, the response also returns an instance ID. Use this instance ID to verify the result on the product console.