All Products
Search
Document Center

Object Storage Service:Installation

Last Updated:Dec 19, 2023

OSS SDK for Java allows you to programmatically manage resources in Object Storage Service (OSS). For example, you can manage buckets, upload objects, download objects, and process images. This topic describes how to install OSS SDK for Java.

Prerequisites

Java 1.7.0 or later is installed.

You can run the java -version command to check the Java version.

Download OSS SDK for Java

Install OSS SDK for Java

You can use one of the following methods to install OSS SDK for Java.

Note

Select an appropriate version of OSS SDK for Java based on your requirements. We recommend that you use the latest version.

Add the dependency to your Maven project (recommended)

To use OSS SDK for Java in Maven, add the SDK dependency by including the following <dependencies> configurations in the pom.xml file:

Note

We recommend that you use the dependency on the latest SDK. In this example, OSS SDK for Java V3.15.1 is used.

<dependency>
    <groupId>com.aliyun.oss</groupId>
    <artifactId>aliyun-sdk-oss</artifactId>
    <version>3.15.1</version>
</dependency>

If you use Java 9 or later, add jaxb-related dependencies. The following code provides an example on how to add jaxb-related dependencies:

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>
<!-- no more than 2.3.3-->
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.3</version>
</dependency>

Import the JAR package to an Eclipse project

For OSS SDK for Java 3.15.1, perform the following steps to import the JAR package to your project:

  1. Download the OSS SDK for Java package.

  2. Decompress the package.

  3. Copy the aliyun-sdk-oss-3.15.1.jar file and all files in the lib directory to your project.

  4. Right-click your project name in Eclipse and choose Properties > Java Build Path > Add JARs.

  5. Select all JAR files that you copied and import the files to Libraries.

Import the JAR files to an IntelliJ IDEA project

For OSS SDK for Java 3.15.1, perform the following steps to import the JAR package to your project:

  1. Download the OSS SDK for Java package.

  2. Decompress the package.

  3. Copy the aliyun-sdk-oss-3.15.1.jar file and all JAR files in the lib directory to your project.

  4. Right-click your project name in IntelliJ IDEA and choose File > Project Structure > Modules > Dependencies > + > JARs or directories.

  5. Select all JAR files that you copied and import the files to External Libraries.

What to do next

After you install OSS SDK for Java, you need to configure access credentials. For more information, see Configure access credentials.