root/main/trunk/gli/findjava.bat @ 32285

Revision 31852, 4.0 KB (checked in by ak19, 2 years ago)

Java code no longer works out what the ultimate URL to download from is, after all the redirects have been resolved. Wget seems to handle some of this, and for the rest, assume the user specificed URL is what the user is after

  • Property svn:executable set to *
Line 
1@echo off
2setlocal enabledelayedexpansion
3
4:: Environment Variables passed in: _VERSION, GLILANG and possibly also
5:: GSDLHOME and/or GSDL3SRCHOME.
6:: As a result of executing this script, the JAVA_EXECUTABLE and GS_JAVA_HOME
7:: environment variables will be set, but only if Perl was found.
8
9:findJava
10
11:: We will already be in the correct folder (GLI folder), which would
12:: contain a compiled up search4j.exe if this GLI is part of an installation.
13:: If search4j.exe is not there, then it means this is an SVN checkout.
14:: In such a case, it's up to the user checking things out to ensure JAVA_HOME
15:: is set and moreover points to the correct version of the Java.
16
17set DISPLAY_MIN_VERSION=1.4
18set MIN_VERSION=1.4.0_00
19set SEARCH4J_EXECUTABLE=search4j.exe
20if exist %SEARCH4J_EXECUTABLE% goto setJexec
21if "%_VERSION%" == "" goto tryJava
22    :: else we look for a compiled version of search4j in a GS installation
23    if "%_VERSION%" == "2" (
24        set SEARCH4J_EXECUTABLE=!GSDLHOME!\bin\windows\search4j.exe
25        set HINT=!GSDLHOME!\packages\jre
26    )
27    if "%_VERSION%" == "3" (
28        set SEARCH4J_EXECUTABLE=!GSDL3SRCHOME!\bin\search4j.exe
29        set HINT=!GSDL3SRCHOME!\packages\jre
30    )
31    if not exist "%SEARCH4J_EXECUTABLE%" goto tryJava
32
33:setJexec
34    "%SEARCH4J_EXECUTABLE%" -e -m "%MIN_VERSION%" -p "%HINT%" | winutil\setvar.exe JAVA_EXECUTABLE > %TMP%\set_java_executable.bat
35    call "%TMP%\set_java_executable.bat"
36    del "%TMP%\set_java_executable.bat"
37   
38    if "%JAVA_EXECUTABLE%" == "" goto noJava
39    echo Java:
40    echo %JAVA_EXECUTABLE%
41    echo.
42
43    :: we know that works, so we can set the local javahome (for Greenstone) as well
44    "%SEARCH4J_EXECUTABLE%" -m "%MIN_VERSION%" -p "%HINT%" | winutil\setvar.exe GS_JAVA_HOME > %TMP%\set_java_home.bat
45    call "%TMP%\set_java_home.bat"
46    del "%TMP%\set_java_home.bat"
47
48    ::set JAVA_HOME=%GS_JAVA_HOME%
49    ::set PATH=%GS_JAVA_HOME%\bin;%PATH%
50   
51:: found java, JAVA_EXECUTABLE and GS_JAVA_HOME env vars set, can exit this script
52    goto exit
53
54:tryJava
55if "%JAVA_HOME%" == "" goto noJava
56if not exist "%JAVA_HOME%\bin\java.exe" goto noJava
57    if "%GLILANG%" == "en" (
58        echo.
59        echo ***************************************************************************
60            echo WARNING:
61        echo Java Runtime not bundled with this Greenstone installation.
62        echo Using JAVA_HOME: !JAVA_HOME!
63        echo ^(NOTE: this needs to be %DISPLAY_MIN_VERSION% or higher.^)
64        echo ***************************************************************************
65        echo.
66    )
67    :: Try to use this version
68    set JAVA_EXECUTABLE=%JAVA_HOME%\bin\java
69    set GS_JAVA_HOME=%JAVA_HOME%
70    ::set JAVA_HOME=%GS_JAVA_HOME%
71    ::set PATH=%GS_JAVA_HOME%\bin;%PATH%
72    goto exit
73
74:noJava
75    echo.
76    if "%GLILANG%" == "en" (
77        echo Failed to locate an appropriate version of Java. You must install a
78            echo Java Runtime Environment ^(version %DISPLAY_MIN_VERSION% or greater^) before running the
79            echo Greenstone Librarian Interface.
80    )
81
82    if "%GLILANG%" == "es" (
83        echo No se pudo localizar una versi¢n apropiada de Java. Usted deber
84            echo instalar un Ambiente de Ejecuci¢n Java ^(versi¢n %DISPLAY_MIN_VERSION% o superior^)
85            echo antes de correr la Interfaz de la Biblioteca Digital Greenstone.
86    )
87
88    if "%GLILANG%" == "fr" (
89        echo Une version ad?quate de Java n'a pas pu ?tre localis?e. Vous devez
90            echo installer un Java Runtime Environment ^(version %DISPLAY_MIN_VERSION% ou sup?rieur^)
91            echo avant de d?marrer Greenstone Librarian Interface.
92    )
93
94    if "%GLILANG%" == "ru" (
95        echo ¥ 〠«®áì ®¯à¥€¥«šâì ¬¥áâ®­ 宊€¥­š¥ ᮮ⢥âáâ¢ãî饩 ¢¥àᚚ Java.
96            echo ?ë €®«Š­ë ãáâ ­®¢šâì Java Runtime Environment ^(¢¥àášî %DISPLAY_MIN_VERSION% š«š ¢ëè¥^) ¯¥à¥€ ¢¢®€®¬
97            echo ¡š¡«š®â¥ç­®£® š­â¥àä¥©á  Greenstone.
98    )
99    goto exit
100
101:exit
102set SEARCH4J_EXECUTABLE=
103set MIN_VERSION=
104set DISPLAY_MIN_VERSION=
105
106endlocal & set JAVA_EXECUTABLE=%JAVA_EXECUTABLE%& set GS_JAVA_HOME=%GS_JAVA_HOME%
107::& set JAVA_HOME=%JAVA_HOME%& set PATH=%PATH%
108
109::echo ** JAVA_HOME: %JAVA_HOME%
110::echo ** PATH: %PATH%
Note: See TracBrowser for help on using the browser.