百度智能云

All Product Document

          Reference

          Java-SDK Getting Started Guide

          Precondition

          This article aims to help you quickly get the Baidu AI Cloud Java SDK and start calling.

          Precondition

          Before development, make sure the following prerequisites are ready:

          • Java SDK toolkit can run under jdk1.7 or jdk1.8.
          • **AK/SK**: AK/SK parameters must be passed in for SDK authentication, and the Access Key and Secret Key can be obtained at Security Authentication Page.

            You can interact with Baidu AI Cloud by two means, including authentication method and anonymous method. For authentication method, you need to verify the identity of a request sender by using Access Key Id / Secret Access Key encryption method. Access Key Id (AK) is used to identify users, and Secret Access Key (SK) is a key used by users to encrypt authentication string and by Baidu AI Cloud to verify the authentication string, where SK must be confidential, which can only be known by users and Baidu AI Cloud.

          Install SDK Package

          • Method one: Installation using Maven

            Add the BCE-Java SDK dependency to the file in Maven's pom.xml:

              <dependency>
                 <groupId>com.baidubce</groupId>
                 <artifactId>bce-java-sdk</artifactId>
                 <version>{version}</version>
             </dependency>

            Among them, {version} is the version number, which can be downloaded from the SDK page.

          • Method two: Install directly using JAR package

            Download the Java SDK compression toolkit at Baidu AI Cloud Official Website. After decompressing bce-java-sdk-version.zip, copy it to the project folder Right click on Eclipse "Project > Properties > Java Build Path >Add JAR" Add SDK package tool lib/bce-java-sdk-version.jar adverbial clause: Third-party dependency kit third-party/*.Ja Among them, version is the version number.

          SDK's directory structure

           com.baidubce 
                  ├── auth                                        //  BCE's signature related class 
                  ├── http                                        /  / BCE's Http communication related class 
                  ├── internal                                    //  SDK's internal class 
                  ├── model                                       //  BCE's public model class 
                  ├── services 
                  │        └── iotdm  Examples of property management services 
                  │           ├── model                            //  Material management internal model, such as Request or Response 
                  │           └── IotDmV3Client.class                //  Taking the object management service as an example, the object management client entry class 
                  ├── util                                        //  BCE's utility tool class 
                  ├── BceClientConfiguration.class                //  Configuration of BCE's HttpClient 
                  ├── BceClientException.class                    //  Exception class of BCE's client 
                  ├── BceServiceException.class                   //  The exception class after interacting with the BCE's server 
                  ├── ErrorCode.class                             //  BCE's general error code 
                  └── Region.class                                //  BCE's service region 

          Use of Java SDK

          3 main steps to call Java SDK:

          • Create and initialize xxxClient. Baidu AI Cloud Service is configured with a detailed Java SDK help guide. For details, please see the product guide.
          • Create an API request and set parameters.
          • Initiate a request and handle a response or exception.
          Previous
          Region Selection Introduction
          Next
          PHP-SDK Getting Started Guide