Changeset 31983
- Timestamp:
- 2017-09-22T20:10:10+12:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/setup.bat
r31854 r31983 158 158 @call "!GSDLHOME!\bin\script\checkwritability.bat" 159 159 160 :::::::::::::::::::::::::::::: 161 if "!GSDL3SRCHOME!" == "" (goto javacheck) else (goto done) 162 163 :javacheck 164 :: Only for GS2: work out java, and if the bundled jre is found, then set Java env vars with it 165 :: Then the same java will be consistently available for all aspects of GS2 (server or GLI, and any subshells these launch) 166 echo. 167 set MINIMUM_JAVA_VERSION=1.5.0_00 168 echo GS2 installation: Checking for Java of version !MINIMUM_JAVA_VERSION! or above 169 170 set BUNDLED_JRE=!GSDLHOME!\packages\jre 171 if exist "!BUNDLED_JRE!" ( 172 set HINT=!BUNDLED_JRE! 173 ) else ( 174 echo No bundled JRE 175 set HINT= 176 ) 177 178 set SEARCH4J_EXECUTABLE=!GSDLHOME!\bin\!GSDLOS!\search4j.exe 179 if not exist "!SEARCH4J_EXECUTABLE!" ( 180 echo Can't check for java, no Search4j 181 if not exist "!BUNDLED_JRE!" echo Ensure Java environment variables are set ^(either JAVA_HOME or JRE_HOME and on PATH^) & goto done 182 :: else use Bundled JRE 183 echo Will use the bundled JRE and unset any JAVA_HOME to prevent conflicts 184 set JAVA_HOME= 185 set JRE_HOME=!BUNDLED_JRE! 186 set PATH=!BUNDLED_JRE!\bin;!PATH! 187 goto done 188 ) 189 190 for /F "tokens=*" %%r in ('bin\!GSDLOS!\search4j.exe -p "!HINT!" -m !MINIMUM_JAVA_VERSION!') do set GS_JAVA_HOME=%%r 191 192 if "!GS_JAVA_HOME!" == "" ( 193 if not exist "!BUNDLED_JRE!" echo There's no bundled JRE. 194 echo setup.bat: Could not find Java in the environment or installation. 195 echo Set JAVA_HOME or JRE_HOME, and put it on the PATH, if working with Java tools like Lucene. 196 goto done 197 ) 198 199 :: found java, now GS_JAVA_HOME env vars set, set JAVA_HOME else JRE_HOME 200 201 if "!GS_JAVA_HOME!" == "!BUNDLED_JRE!" ( 202 :: since our bundled JRE was selected by search4j and we'll be using that, clearing any existing JAVA_HOME to prevent version conflicts 203 echo Found a bundled JRE. Setting up GS2's Java environment to use this ^(and unsetting any JAVA_HOME to prevent version conflicts^) 204 set JAVA_HOME= 205 set JRE_HOME=!BUNDLED_JRE! 206 set PATH=!BUNDLED_JRE!\bin;!PATH! 207 goto done 208 ) 209 210 :: Otherwise, the java that search4j found is not the bundled jre. In that case 211 :: if JAVA_HOME or JRE_HOME is already set to the Java found, then PATH presumably would already be set too. 212 if "!JAVA_HOME!" == "!GS_JAVA_HOME!" ( 213 echo Looks like the Java environment is already set up with a JAVA_HOME 214 ::echo Looks like the Java environment is already set up with a JAVA_HOME, unsetting any JRE_HOME 215 goto done 216 ) 217 if "!JRE_HOME!" == "!GS_JAVA_HOME!" ( 218 echo Looks like the Java environment is already set up with a JRE_HOME, unsetting any JAVA_HOME to prevent java version conflicts 219 set JAVA_HOME= 220 goto done 221 ) 222 223 :: if Java env vars not already set, then set them to the GS_JAVA_HOME found 224 echo Found a Java on the system. Setting up GS2's Java environment to use this 225 ::echo Found a Java on the system. Setting up GS2's Java environment to use this: !GS_JAVA_HOME! 226 set PATH=!GS_JAVA_HOME!\bin;!PATH! 227 :: extract the last 4 chars from folder name. Could be \jre or jre\ or otherwise 228 set javafoldername=!GS_JAVA_HOME:~-4! 229 :: now can test if the foldername contains jre or otherwise, and based on that set either JAVA_HOME or JRE_HOME 230 :: https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file 231 :: https://ss64.com/nt/syntax-substring.html 232 if /i "x!javafoldername:jre=!" == "x!javafoldername!" ( 233 echo Setting JAVA_HOME, and unsetting any JRE_HOME to prevent version conflicts 234 set JAVA_HOME=!GS_JAVA_HOME! 235 set JRE_HOME= 236 ) else ( 237 echo Setting JRE_HOME, and unsetting any JAVA_HOME to prevent version conflicts 238 set JRE_HOME=!GS_JAVA_HOME! 239 set JAVA_HOME= 240 ) 241 242 :::::::::::::::::::::::::::::: 243 160 244 :done 161 245 popd 162 endlocal & set PATH=%PATH%& set GSDLHOME=%GSDLHOME%& set GSDLOS=%GSDLOS% 246 endlocal & set PATH=%PATH%& set GSDLHOME=%GSDLHOME%& set GSDLOS=%GSDLOS%& set JRE_HOME=%JRE_HOME%& set JAVA_HOME=%JAVA_HOME% 247 248 if not "%JAVA_HOME%" == "" echo JAVA_HOME: %JAVA_HOME% 249 if not "%JRE_HOME%" == "" echo JRE_HOME: %JRE_HOME% 250 if "%JAVA_HOME%" == "" if "%JRE_HOME%" == "" echo Warning: Neither JAVA_HOME nor JRE_HOME set. Ensure one is set and on PATH. 163 251 164 252 :: Perl >= v5.18.* randomises map iteration order within a process
Note:
See TracChangeset
for help on using the changeset viewer.