Last Updated: Oct 10, 2017

Prepare the environment

Applicable to JDK 6 and later version.

Installation methods

To use the OSS Java SDK in Maven, you only need to add the corresponding dependency to the pom.xml file. Take the 2.7.0 version as an example. Add the following content to the “dependencies” tab:

  1. <dependency>
  2. <groupId>com.aliyun.oss</groupId>
  3. <artifactId>aliyun-sdk-oss</artifactId>
  4. <version>2.7.0</version>
  5. </dependency>

Method 2: Import a JAR package to your Eclipse project

Take the 2.7.0 version as an example. Follow these steps:

  1. Download the Java SDK

  2. Unzip the SDK.

  3. Copy the files in the unzipped folder aliyun-sdk-oss-<versionId>.jar and all the files under the lib folder to your project.

  4. In Eclipse, right click your project and select Properties > Java Build Path > Add JARs.

  5. Select all JAR files that you have copied in Step 3.

When you complete the preceding steps, you can use the OSS Java SDK in Eclipse.

Example project

OSS Java SDK provides example projects of Maven and Ant. You can compile and run the example projects in a local device. You can also develop your own apps based on the example project.


  • Before compilation and run, modify endpoint/accessKeyId/accessKeySecret/bucketName in to your real information.
  • For project compilation and running methods, see the in the project directory.

Example project

OSS Java SDK provides rich example projects for your reference or use. You can get an example project through the following two methods:

  • View in GitHub and download the desired project. The src/samples under the OSS Java SDK GitHub contains the example projects.
  • Download the OSS Java SDK, such as Unzip the package and the “aliyun_java_sdk_20170629/samples” contains the example projects.

The example includes the following content:

Example file Example content Demonstrate basic Upload and Download usage Demonstrate Object Downloading usage Demonstrate List Objects usage Demonstrate Delete Objects by Batch usage Demonstrate Append Upload usage Demonstrate Object Metadata usage How to create a folder. For detailed descriptions of OSS folders, see Folders Demonstrate Resumable Upload usage Demonstrate Resumable Download usage Demonstrate Image Service usage Demonstrate PostObject usage. The implementation is not dependent on the Java SDK Demonstrate the usage of uploading/downloading Progress Bar Demonstrate Upload Callback usage Demonstrate uploading and downloading CRC Verification Demonstrate the bucket configuration usage, including ACL, Lifecycle, Log, Anti-leech and CORS Resumable Upload (uploadFile) is recommended directly for concurrent uploads implemented by multipart upload interface Resumable Download (downloadFile) is recommended directly for concurrent downloads implemented by download within a specified range Demonstrate the usage of multipart copy of large objects
Thank you! We've received your feedback.