pokero pokero - 3 months ago 40
Java Question

java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials

I am running the Glacier API for AWS, just a very basic version - trying to list my vaults.

I followed the example at http://docs.aws.amazon.com/amazonglacier/latest/dev/creating-vaults-sdk-java.html#creating-vaults-sdk-java-example.

I am running from the command line on Linux. It compiles fine:

javac -cp sdk/lib/aws-java-sdk-1.7.3.jar -d bin src/AmazonGlacierVaultInfo.java


But when running, I get:

java -cp "bin: sdk/lib*" AmazonGlacierVaultInfo

Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials


It seems the SDK classes in the sdk jar are not being found.

I have my classpath correct though I think:

./:/home/name/sites/git/glacier/bin/:/home/name/sites/git/glacier/sdk/:/home/name/sites/git/glacier/src/


I run and compile from /home/name/sites/git/glacier, which has bin, src and sdk directories as detailed on http://docs.aws.amazon.com/amazonglacier/latest/dev/using-aws-sdk-for-java.html#setting-up-and-testing-sdk-java-commandline

Any help would be greatly appreciated.

Answer

A few issues

  • Add a forward slash to parse the contents of your lib directory
  • Remove the space from the classpath
  • the surrounding quotes are unnecessary

command:

java -cp bin:sdk/lib/* AmazonGlacierVaultInfo