source: main/trunk/greenstone2/findjava.bat@ 31830

Last change on this file since 31830 was 24829, checked in by ak19, 12 years ago

Changes to bat files and perl code to deal with brackets in (Windows) filepath. Also checked winmake.bat files to see if changes were needed there. These changes go together with the commits 24826 to 24828 for gems.bat, and commit 24820 on makegs2.bat.

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