views:

702

answers:

3

I'm having a problem getting my android dev environment setup in Windows 7. I follow the instructions here, as well as several environment sublinks. I am using Eclipse with the Android plugin. I have installed the Java JDK several times, in various locations (jdk-6u20-windows-i586.exe) - but I am obviously missing something.

Every time I run "android create avd --target 2 --name my_avd" I get an error:

    C:\Users\andrew>android create avd --target 2 --name my_avd

WARNING: Java not found in your path.
Checking it it's installed in C:\Program Files\Java instead.


ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java installed on your system. We
recommend that you install the JDK version of JavaSE, available here:
  http://java.sun.com/javase/downloads/

You can find the complete Android SDK requirements here:
  http://developer.android.com/sdk/requirements.html

This error message is the reason for me installing the JDK several times over. First I tried installing to a location on my e: drive. I then moved it to the default loc (program files (x86)\java\jdk.6.something. I also tried forcing it to go into the program files\ path, but it still automatically installs into the (x86) path. I have added the install path to my path environment variable every single time, yet I still continue to get this error. My suspicion is that windows 7 and the android tools are not playing together well in terms of finding the JDK, but who knows, it may be something entirely different. If you have seen this error before, I would appreciate a hint.

A: 

The android command is just a Windows Batch file which in turn uses the batch file tools\lib\find_java.bat to find Java.

Having a look at the source, it does the following:

  1. Looks to see if java.exe is on your PATH.
  2. Looks for java.exe in somewhere under %ProgramFiles%

Your problem arises because you're using the a 64-bit version of Windows. This means %ProgramFiles% is C:\Program Files but Java is installed in C:\Program Files (x86) as it's a 32-bit application, meaning find_java.bat doesn't find it.

So to fix this you'll need to add the directory containing java.exe to your PATH environment variable.

You'll need to the add the directory containing java.exe - something like C:\Program Files (x86)\Java\jdk6\bin - on to the end of PATH with a semicolon in front of it to separate it from the previous entry.

This question on superuser.com covers maintaining Environment Variables in Windows 7.

Dave Webb
Ok, so the top level path of the install was not enough, I needed to drill down a directory or two apparently. I will try that when I get home tonight. Thanks
reuscam
You need to add the directory which actually contains `java.exe`
Dave Webb
A: 

how do u downlaod the JDK to ur desktop

Nicholas Owens
A: 

I had this same problem, after accidentally installed the 32-bit version of Java SDK. I uninstalled it and installed the 64-bit version (since I'm using Windows 7 64). The Android SDK setup never found Java correctly, even after I added it to my PATH variable!

After a bit of digging around, I discovered a java.exe floating around in my system32 folder, which in the order of the PATH variable came before my SDK path. After whacking the java.exe in my system32 folder, the Android Setup ran just fine!

Hope this helps.

Eric