Install the DBRC SDK for Java, configure your credentials, and make your first API call.
Prerequisites
Environment requirements
-
JDK 1.8 or later is installed. Java Downloads.
-
IntelliJ IDEA is installed. IntelliJ IDEA.
-
An AccessKey pair is created for API authentication. An AccessKey pair consists of an AccessKey ID and an AccessKey secret. Create one on the Security Management page. Create an AccessKey pair.
Java version
Run java -version to verify your installation.
Sample code
Step 1: Download an SDK project
-
Log on to OpenAPI Explorer.
-
In the top navigation bar, click Cloud Products and select your cloud service.
-
On the Product Homepage, click API Debugging in the top navigation bar.
-
Select an API operation in the left column, configure parameters in the middle column, and click the SDK Sample Code tab in the right column.
-
Select V2.0 from the SDK Generation drop-down list and choose a programming language.
-
Click Download Project.
-
To generate generic code, turn on Common Request. Generic calls and specialized calls.
Step 2: Configure environment variables
-
Run the following commands in a terminal. Replace
<access_key_id>and<access_key_secret>with your actual values.export ALIBABA_CLOUD_ACCESS_KEY_ID=<ACCESS_KEY_ID> export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ACCESS_KEY_SECRET> -
Restart IntelliJ IDEA to load the new environment variables.
NoteOn Linux, these
exportcommands create temporary environment variables that apply only to the current shell session. For example, runmvn packageto build a JAR file, then runjava -jar <jarfilepath>in the same session.
Step 3: Run the code
-
Run the code in IntelliJ IDEA. Check the console output for the response and
request ID. -
If the API operation creates an instance, the response includes the instance ID. Verify the result in the Alibaba Cloud console.