edit-icon download-icon


Last Updated: Apr 17, 2018

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 aliyun_java_sdk_20171127.zip.
  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.

After you complete the preceding 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 ‘HelloOSS.java’ to match your real information.
  • For project compilation and running methods, see the ‘README.md’ file 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 contains sample programs.
  • Download the OSS Java SDK, such as aliyun_java_sdk_20171127.zip. Unzip the package and the aliyun_java_sdk_20171127/samples contains the sample programs.

The sample includes the following content:

Sample file Sample content
GetStartedSample.java Demonstrate basic Upload and Download operations
SimpleGetObjectSample.java Demonstrate Object Download operations
ListObjectsSample.java Demonstrate List Objects operations
DeleteObjectsSample.java Demonstrate Delete Objects by Batch operations
AppendObjectSample.java Demonstrate Append Upload operations
ObjectMetaSample.java Demonstrate Object Metadata operations
CreateFolderSample.java Demonstrate how to create a folder. For more information about the OSS folders, see Folders
UploadSample.java Demonstrate Resumable Upload operations
DownloadSample.java Demonstrate Resumable Download operations
ImageSample.java Demonstrate Image Processing Service operations
PostObjectSample.java Demonstrate PostObject operations. The implementation does not depend on the Java SDK
GetProgressSample.java Demonstrate upload/download Progress Bar operations
CallbackSample.java Demonstrate Upload Callback operations
CRCSample.java Demonstrate operations for upload and download CRC Verification
BucketOperationsSample.java Demonstrate the bucket configuration operations, including ACL, Lifecycle, Log, Anti-leech and CORS
MultipartUploadSample.java Demonstrate how to use the multipart upload interface to upload objects in concurrency. We recommend using Resumable Upload (uploadFile)
ConcurrentGetObjectSample.java Demonstrate how to download objects in concurrency using range-specific download. We recommend using Resumable Download (downloadFile)
UploadPartCopySample.java Demonstrate operations of multipart copy for large objects
Thank you! We've received your feedback.