Help Center> Object Storage Service> Java> SDK Download and Installation (SDK for Java)
Updated on 2024-01-26 GMT+08:00

SDK Download and Installation (SDK for Java)

Downloading OBS SDK for Java

  • Latest version of OBS Java SDK source code: Download
  • Earlier version of OBS Java SDK: Download

If you need to add the SDK as a dependency in your Maven project, see Installing OBS SDK for Java.

Installing OBS SDK for Java

You can use the methods listed in Table 1 to install OBS SDK for Java.

Method 1: Using the Maven Central Repository and Maven Project

Before using this method, ensure that the Java and Maven environments are correctly configured and can be used properly.

  1. Access the Maven central repository to obtain the version number of OBS SDK for Java. You can either choose an OBS Bundle SDK for Java or a standard OBS SDK for Java. No matter Bundle or standard SDKs, a latest version is recommended. Bundle SDK 3.23.9 is used here.

    • Bundle SDKs share the same source code as standard SDKs. The difference is that in Bundle SDKs, all third-party dependencies are organized into the SDK and are added from the SDK path. This means Bundle SDKs are freed from potential external dependency conflicts but require a larger space (over 7 MB).
    • If there is a dependency conflict when you use a standard SDK, resolve the issue by referring to Resolving Dependency Missing or Conflicts (SDK for Java).

  2. Open the pom.xml file of the Maven project and add dependency configurations to <dependencies>.

    If you choose to use a Bundle SDK, add the following configuration to <dependencies> and replace bundleVersionNumber with the SDK version number obtained in 1:

    1
    2
    3
    4
    5
    <dependency>
       <groupId>com.huaweicloud</groupId>
       <artifactId>esdk-obs-java-bundle</artifactId>
       <version>bundleVersionNumber</version>
    </dependency>
    

    In this example, the configurations shown below should be added for Bundle 3.23.9:

    1
    2
    3
    4
    5
    <dependency>
       <groupId>com.huaweicloud</groupId>
       <artifactId>esdk-obs-java-bundle</artifactId>
       <version>3.23.9</version>
    </dependency>
    

    If you choose to use a standard SDK, add the following configuration to <dependencies> and replace VersionNumber with the SDK version number obtained in 1:

    1
    2
    3
    4
    5
    <dependency>
       <groupId>com.huaweicloud</groupId>
       <artifactId>esdk-obs-java</artifactId>
       <version>versionNumber</version>
    </dependency>
    

  3. Click Reload All Maven Projects to refresh the Maven configuration.
  4. Check whether the SDK is successfully installed. If a JAR package for Java SDK is downloaded to the dependency path, the SDK is installed. If no JAR package is generated, check whether the pom.xml file is correctly configured and the version number of SDK is correctly replaced. If the fault persists, submit a service ticket.

Method 2: Using the Gradle Central Repository and Gradle Project

Before using this method, ensure that the Java and Gradle environments are correctly configured and can be used properly.

  1. Obtain the version number of OBS SDK for Java. You can either choose an OBS Bundle SDK for Java or a standard OBS SDK for Java. No matter Bundle or standard SDKs, a latest version is recommended. Bundle 3.23.9 is used here.

    • Bundle SDKs share the same source code as standard SDKs. The difference is that in Bundle SDKs, all third-party dependencies are organized into the SDK and are added from the SDK path. This means Bundle SDKs are freed from potential external dependency conflicts but require a larger space (over 7 MB).
    • If there is a dependency conflict when you use a standard SDK, resolve the issue by referring to Resolving Dependency Missing or Conflicts (SDK for Java).

  2. Open the build.gradle file of the Gradle project and add the dependency configurations to dependencies.

    If you choose to use a Bundle SDK, add the following configuration to <dependencies> and replace bundleVersionNumber with the SDK version number obtained in 1:

    1
    api 'com.huaweicloud:esdk-obs-java-bundle:bundleVersionNumber'
    

    In this example, the configurations shown below should be added for Bundle 3.23.9:

    1
    api 'com.huaweicloud:esdk-obs-java-bundle:3.23.9'
    

    If you choose to use a standard SDK, add the following configurations to <dependencies> and replace VersionNumber with the SDK version number obtained in 1:

    1
    api 'com.huaweicloud:esdk-obs-java:versionNumber'
    

  3. Click Reload All Gradle Projects to refresh the Gradle configuration.
  4. Check whether the SDK is successfully installed. If a JAR package for Java SDK is downloaded to the dependency path, the SDK is installed. If no JAR package is generated, check whether the build.gradle file is correctly configured and the version number of SDK is correctly replaced. If the fault persists, submit a service ticket.