| Raphael | 047e5f5 | 2010-01-26 16:08:17 -0800 | [diff] [blame] | 1 | @echo off
|
| 2 | rem Copyright (C) 2007 The Android Open Source Project
|
| 3 | rem
|
| 4 | rem Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 | rem you may not use this file except in compliance with the License.
|
| 6 | rem You may obtain a copy of the License at
|
| 7 | rem
|
| 8 | rem http://www.apache.org/licenses/LICENSE-2.0
|
| 9 | rem
|
| 10 | rem Unless required by applicable law or agreed to in writing, software
|
| 11 | rem distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 | rem See the License for the specific language governing permissions and
|
| 14 | rem limitations under the License.
|
| 15 |
|
| 16 | rem This script is called by the other batch files to find a suitable Java.exe
|
| 17 | rem to use. The script changes the "java_exe" env variable. The variable
|
| 18 | rem is left unset if Java.exe was not found.
|
| 19 |
|
| 20 | rem Useful links:
|
| 21 | rem Command-line reference:
|
| 22 | rem http://technet.microsoft.com/en-us/library/bb490890.aspx
|
| 23 |
|
| 24 | rem Check we have a valid Java.exe in the path. The return code will
|
| 25 | rem be 0 if the command worked or 9009 if the exec failed (program not found).
|
| 26 | rem Java itself will return 1 if the argument is not understood.
|
| 27 | set java_exe=java
|
| 28 | %java_exe% -version 2>nul
|
| 29 | if ERRORLEVEL 1 goto SearchForJava
|
| 30 | goto :EOF
|
| 31 |
|
| 32 |
|
| 33 | rem ---------------
|
| 34 | :SearchForJava
|
| 35 | rem We get here if the default %java_exe% was not found in the path.
|
| 36 | rem Search for an alternative in %ProgramFiles%\Java\*\bin\java.exe
|
| 37 |
|
| 38 | echo.
|
| Raphael | ea66c92 | 2010-01-27 12:48:34 -0800 | [diff] [blame] | 39 | echo WARNING: Java not found in your path.
|
| Raphael Moll | a5dd865 | 2010-08-20 21:54:59 -0700 | [diff] [blame] | 40 |
|
| 41 | rem Check if there's a 64-bit version of Java in %ProgramW6432%
|
| 42 | if not defined ProgramW6432 goto :Check32
|
| 43 | echo Checking if it's installed in %ProgramW6432%\Java instead (64-bit).
|
| 44 |
|
| 45 | set java_exe=
|
| 46 | for /D %%a in ( "%ProgramW6432%\Java\*" ) do call :TestJavaDir "%%a"
|
| 47 | if defined java_exe goto :EOF
|
| 48 |
|
| 49 | rem Check for the "default" 32-bit version
|
| 50 | :Check32
|
| 51 | echo Checking if it's installed in %ProgramFiles%\Java instead.
|
| Raphael | 047e5f5 | 2010-01-26 16:08:17 -0800 | [diff] [blame] | 52 |
|
| 53 | set java_exe=
|
| 54 | for /D %%a in ( "%ProgramFiles%\Java\*" ) do call :TestJavaDir "%%a"
|
| 55 | if defined java_exe goto :EOF
|
| 56 |
|
| 57 | echo.
|
| Raphael | ea66c92 | 2010-01-27 12:48:34 -0800 | [diff] [blame] | 58 | echo ERROR: No suitable Java found. In order to properly use the Android Developer
|
| Raphael Moll | a5dd865 | 2010-08-20 21:54:59 -0700 | [diff] [blame] | 59 | echo Tools, you need a suitable version of Java JDK installed on your system.
|
| 60 | echo We recommend that you install the JDK version of JavaSE, available here:
|
| 61 | echo http://www.oracle.com/technetwork/java/javase/downloads
|
| Raphael | 047e5f5 | 2010-01-26 16:08:17 -0800 | [diff] [blame] | 62 | echo.
|
| 63 | echo You can find the complete Android SDK requirements here:
|
| 64 | echo http://developer.android.com/sdk/requirements.html
|
| 65 | echo.
|
| 66 | goto :EOF
|
| 67 |
|
| 68 | rem ---------------
|
| 69 | :TestJavaDir
|
| 70 | rem This is a "subrountine" for the for /D above. It tests the short version
|
| 71 | rem of the %1 path (i.e. the path with only short names and no spaces).
|
| 72 | rem However we use the full version without quotes (e.g. %~1) for pretty print.
|
| 73 | if defined java_exe goto :EOF
|
| 74 | set full_path=%~1\bin\java.exe
|
| 75 | set short_path=%~s1\bin\java.exe
|
| Raphael | 047e5f5 | 2010-01-26 16:08:17 -0800 | [diff] [blame] | 76 |
|
| 77 | %short_path% -version 2>nul
|
| 78 | if ERRORLEVEL 1 goto :EOF
|
| 79 | set java_exe=%short_path%
|
| 80 |
|
| 81 | echo.
|
| 82 | echo Java was found at %full_path%.
|
| 83 | echo Please consider adding it to your path:
|
| 84 | echo - Under Windows XP, open Control Panel / System / Advanced / Environment Variables
|
| Raphael Moll | a5dd865 | 2010-08-20 21:54:59 -0700 | [diff] [blame] | 85 | echo - Under Windows Vista or Windows 7, open Control Panel / System / Advanced System Settings / Environment Variables
|
| Raphael | 047e5f5 | 2010-01-26 16:08:17 -0800 | [diff] [blame] | 86 | echo At the end of the "Path" entry in "User variables", add the following:
|
| 87 | echo ;%full_path%
|
| 88 | echo.
|