7

I installed ec2 command line tools on windows this morning. When I try to run a command ec2-describe-instances in the git bash, I get this output:

Exception in thread "main" java.lang.NoClassDefFoundError: com/amazon/aes/webservices/client/cmd/DescribeInstances
Caused by: java.lang.ClassNotFoundException: 
com.amazon.aes.webservices.client.cmd.DescribeInstances
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.amazon.aes.webservices.client.cmd.DescribeInstances. 
Program will exit.

But if I open up just standard cmd, everything works fine. I want to be able to use my git bash for everything. I noticed that the git bash just uses the cmd prompt but with extra options. The shortcut for the git bash has this in the target:

C:\Windows\System32\cmd.exe /c ""C:\Program Files\Git\bin\sh.exe" --login -i"

How can I get ec2 command line tools running in the git bash?

2

I found a solution here: bash shell does not run .bat files

Run

cmd.exe '/c filename.batorexe' 

in the appropriate directory (you can't do a subfolder for some reason).

  • 1
    While this is an alternative workaround, it was not the root problem. EC2 command line tools for Windows comes with both ec2-describe-instances.cmd windows batch file as well as ec2-describe-instances bash file. – wisbucky Dec 17 '13 at 16:26
2

The difference is that Git Bash (MINGW) doesn't convert some of the environment variables from Windows path format to *nix path format. It does the conversion for PATH, but not EC2_HOME or CLASSPATH.

I had the same error, then after setting these 2 environment variables in Git Bash, the ec2 command line worked great:

export CLASSPATH="/c/Program Files/ec2-api-tools-1.6.6.3/lib"
export EC2_HOME="/c/Program Files/ec2-api-tools-1.6.6.3"

You can add that to .bash_profile to automatically set it whenever you launch Git Bash (instead of changing the Windows environment variables), that way it will work in both Git Bash and Windows command line.

0

Even in git-bash on windows you can enter into CMD mode by typing 'cmd' and then use the commands in normal cmd-way.

So, you could even try that..... this would spare you opening different consoles for different tasks.

0

Your problem is the class that not is found. Seems your bash shell not has access to the same environment cmd shell has. Set up the right environment and the bash shell should work.

  • 2
    How would you go about setting up the environment? Could that be included in your answer? – Simon Sheehan Jan 11 '12 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.