7
votes

I am trying to access my s3 buckets from my java application, trying to implement this

https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/examples-s3-buckets.html

I've added the lib/aws-java-sdk-1.8.6.jar to my lib folder and added the dependency in my pom.xml as well.

I still get this import error

"The import com.amazonaws.services.s3.AmazonS3ClientBuilder cannot be resolved" for "import com.amazonaws.services.s3.AmazonS3ClientBuilder;"

Whereas the imports

"import com.amazonaws.services.s3.AmazonS3;" and "import com.amazonaws.services.s3.model.Bucket;" gave no errors.

Any help would be appreciated. I found some people trying to implement for Android ran in similar issues but not this exactly

6
Version 1.8.6 is quite old. Could you with retry with the current version (1.11.x)? - jarmod
Are you referring /third-party/lib/*.jar on the sdk as Amazon documention suggests? I just download the latest sdk and adding to the classpath both lib/*.jar & /third-party/lib/*.jar works - r.pedrosa
I'm referring to the version of the AWS Java SDK. Is your problem resolved? Also note that when you want to respond to someone's comment on Stackoverflow, you'll need to reference that person (using @username) in the comment otherwise they will not be notified and might miss your response. - jarmod
@jarmod it wasn't that but i still ended up updating it to version 1.11.0. Thank you! thank you for the helpful reply tip too! - obawany
@obawany How did you solve it? changed version? - Itay Feldman

6 Answers

10
votes

I was having the same issue, and after some research I realized that AmazonS3ClientBuilder is not part from AWS Android SDK instead of that the class is part of AWS JAVA SDK so you have to include this on your dependencies:

implementation 'com.amazonaws:aws-java-sdk:1.11.404'

3
votes
  • Definitely the dependency as mentioned in Amazon documentation did not work. The path to the dependency does not exist, in Maven central repository.

    "software.amazon.awssdk" % "aws-java-sdk" % "2.0.0"

  • The following too, did not resolve com.amazonaws.services.s3.AmazonS3ClientBuilder, though the JAR path is correct in Maven central -

    "software.amazon.awssdk" % "aws-sdk-java" % "2.1.3"

  • I had to fallback to the following as mentioned in the previous comment.

    "com.amazonaws" % "aws-java-sdk" % "1.11.465"

1
votes

For people running Spring using Maven build, the pom.xml dependency you need to import com.amazonaws.services.s3.AmazonS3ClientBuilder; into the Java class is this:

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-s3</artifactId>
        <version>1.11.267</version>
    </dependency>
0
votes

The AWS Documentation is not correct, add this to your pom.xml file:

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-sqs</artifactId>
    <version>1.11.1005</version>
</dependency>
0
votes

The AWS Documentation is not correct, add this to your pom.xml file:

<dependency>
  <groupId>software.amazon.awssdk</groupId>
  <artifactId>s3</artifactId>
  <version>2.15.32</version>
</dependency>
0
votes

As I mentioned in my comment - Amazon recommends moving to V2:

The AWS SDK for Java 2.x is a major rewrite of the version 1.x code base. It’s built on top of Java 8+ and adds several frequently requested features. These include support for non-blocking I/O and the ability to plug in a different HTTP implementation at run time.

All V2 examples have been thoroughly unit tested and work (V1 code examples are old).

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/s3