Last Updated: Dec 05, 2017

Prepare the environment

Applicable to JDK 6 and later.


To use the OSS Java SDK in Maven, you only need to add the corresponding dependency to the pom.xml file. Take the 2.8.2 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.8.2</version>
  5. </dependency>

Method 2: Import a JAR package to your Eclipse project

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

  1. Download the Java SDK version
  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 previous steps, you can use the OSS Java SDK in Eclipse.

Sample project

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


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

Sample program

OSS Java SDK provides a variety of sample programs for your reference or use. You can get a sample program through the following two methods:

  • In Github, view and download the OSS Java SDK github. The src/samples directory under it contains sample programs.
  • Download the OSS Java SDK, such as Unzip the package and the aliyun_java_sdk_20171127/samples contains the sample programs.

The sample includes the following content:

Sample file Sample content Demonstrate basic Upload and Download operations Demonstrate Object Download operations Demonstrate List Objects operations Demonstrate Delete Objects by Batch operations Demonstrate Append Upload operations Demonstrate Object Metadata operations Demonstrate how to create a folder. For detailed descriptions of OSS folders, see Folders Demonstrate Resumable Upload operations Demonstrate Resumable Download operations Demonstrate Image Processing Service operations Demonstrate PostObject operations. The implementation is not dependent on the Java SDK. Demonstrate upload/download Progress Bar operations Demonstrate Upload Callback operations Demonstrate operations for upload and download CRC Verification Demonstrate the bucket configuration operations, including ACL, Lifecycle, Log, Anti-leech and CORS. Demonstrate how to use the multipart upload interface to upload objects in concurrency. We recommend you use Resumable Upload (uploadFile). Demonstrate how to download objects in concurrency using range-specific download. We recommend you use Resumable Download (downloadFile). Demonstrate operations of multipart copy for large objects.
Thank you! We've received your feedback.