1@echo off 2rem Copyright (C) 2007 The Android Open Source Project 3rem 4rem Licensed under the Apache License, Version 2.0 (the "License"); 5rem you may not use this file except in compliance with the License. 6rem You may obtain a copy of the License at 7rem 8rem http://www.apache.org/licenses/LICENSE-2.0 9rem 10rem Unless required by applicable law or agreed to in writing, software 11rem distributed under the License is distributed on an "AS IS" BASIS, 12rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13rem See the License for the specific language governing permissions and 14rem limitations under the License. 15 16rem This script is called by the other batch files to find a suitable Java.exe 17rem to use. The script changes the "java_exe" env variable. The variable 18rem is left unset if Java.exe was not found. 19 20rem Useful links: 21rem Command-line reference: 22rem http://technet.microsoft.com/en-us/library/bb490890.aspx 23 24rem Query whether this system is 32-bit or 64-bit 25rem Note: Some users report that reg.exe is missing on their machine, so we 26rem check for that first, as we'd like to use it if we can. 27set sys_32=%SYSTEMROOT%\system32 28if exist %sys_32%\reg.exe ( 29 rem This first-pass solution returns the correct architecture even if you 30 rem call this .bat file from a 32-bit process. 31 rem See also: http://stackoverflow.com/a/24590583/1299302 32 %sys_32%\reg query "HKLM\Hardware\Description\System\CentralProcessor\0"^ 33 | %sys_32%\find /i "x86" > NUL && set arch_ext=32|| set arch_ext=64 34) else ( 35 rem This fallback approach is simpler, but may misreport your architecture as 36 rem 32-bit if running from a 32-bit process. Still, it should serve to help 37 rem our users without reg.exe, at least. 38 if "%PROCESSOR_ARCHITECTURE%" == "x86" (set arch_ext=32) else (set arch_ext=64) 39) 40 41rem Check we have a valid Java.exe in the path. The return code will 42rem be 0 if the command worked or 1 if the exec failed (program not found). 43for /f "delims=" %%a in ('"%~dps0\find_java%arch_ext%.exe" -s') do set java_exe=%%a 44if not defined java_exe goto :CheckFailed 45 46:SearchJavaW 47rem Check if we can find a javaw.exe at the same location than java.exe. 48rem If that doesn't work, just fall back on the java.exe we just found. 49for /f "delims=" %%a in ('"%~dps0\find_java%arch_ext%.exe" -s -w') do set javaw_exe=%%a 50if not exist "%javaw_exe%" set javaw_exe=%java_exe% 51goto :EOF 52 53 54:CheckFailed 55echo. 56echo ERROR: No suitable Java found. In order to properly use the Android Developer 57echo Tools, you need a suitable version of Java JDK installed on your system. 58echo We recommend that you install the JDK version of JavaSE, available here: 59echo http://www.oracle.com/technetwork/java/javase/downloads 60echo. 61echo If you already have Java installed, you can define the JAVA_HOME environment 62echo variable in Control Panel / System / Avanced System Settings to point to the 63echo JDK folder. 64echo. 65echo You can find the complete Android SDK requirements here: 66echo http://developer.android.com/sdk/requirements.html 67echo. 68goto :EOF 69