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.
Select an appropriate version of OSS SDK for Java based on your requirements. We recommend that you use the latest version.
Add dependencies to your Maven project (recommended)
To use OSS SDK for Java in Maven, you need to only add the required dependencies to the pom.xml file. In this example, OSS SDK for Java 3.17.4 is added.
We recommend that you use the dependencies on the latest SDK. For more information about the latest version of OSS SDK for Java, visit GitHub.
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.17.4</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.17.4, perform the following steps to import the JAR package to your project:
Download the OSS SDK for Java package.zip.
Decompress the package.
Copy the aliyun-sdk-oss-3.17.4.jar file and all files in the lib directory to your project.
Right-click your project name in Eclipse and choose
.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.17.4, perform the following steps to import the JAR package to your project:
Download the OSS SDK for Java package.zip.
Decompress the package.
Copy the aliyun-sdk-oss-3.17.4.jar file and all JAR files in the lib directory to your project.
Right-click your project name in IntelliJ IDEA and choose
.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.