Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (19.1k points)

Using this code for setting the classpath

AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();

ec2 = new AmazonEC2Client(credentialsProvider);

Below is the format for AwsCredentials.properties file

# Fill in your AWS Access Key ID and Secret Access Key

# http://aws.amazon.com/security-credentials

accessKey = key here

secretKey = secret key here

Below is the exception I am getting

Exception in thread "main" com.amazonaws.AmazonClientException: Unable to load AWS credentials from the /AwsCredentials.properties file on the classpath

    at com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider.getCredentials(ClasspathPropertiesFileCredentialsProvider.java:81)

    at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:8359)

1 Answer

0 votes
by (44.3k points)

The reason for this exception is because your AWS SDK is not able to load your credentials. Now, do this:

Preference → AWS → Add Secret key and Access key

This will allow your project to retrieve both the keys.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...