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.
A few issues
lib
directorycommand:
java -cp bin:sdk/lib/* AmazonGlacierVaultInfo
I had the same error but i retried as below
add plugin if you also use maven:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
And run:
mvn clean compile assembly:single
It will packaged all dependencies required into one jar then the error will disappear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With