Ignore:
Timestamp:
2007-10-24T09:23:02+13:00 (16 years ago)
Author:
qq6
Message:

looking for the JRE home first then the JAVA home while starting the gs3 server

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/gs3-server.bat

    r13931 r14727  
    11@echo off
    22
    3 set SERVERLANG=en
     3echo Greenstone 3 Server
     4echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
     5echo This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
     6echo This is free software, and you are welcome to redistribute it
    47
    5 :: -------- Run the Greenstone 3 Server --------
    6 
    7 :: This script must be run from within the directory in which it lives
    8 if exist gs3-server.bat goto start
    9     if "%SERVERLANG%" == "en" echo This script must be run from the directory in which it resides.
    10     if "%SERVERLANG%" == "es" echo Este gui¢n deber  ejecutarse desde el directorio en el que reside.
    11     if "%SERVERLANG%" == "fr" echo Ce script doit ˆtre ex‚cut‚ 
 partir du r‚pertoire dans lequel il se trouve.
    12     if "%SERVERLANG%" == "ru" echo â®â áªàš¯â €®«Š¥­ ¡ëâì ¢§ïâ š§ €šà¥ªâ®àšš, ¢ ª®â®à®© ®­ à á¯®«®Š¥­
    13     goto exit
    14 
    15 :start
    16 if "%OS%" == "Windows_NT" goto findGSDL
    17     :: Invoke a new command processor to ensure there's enough environment space
    18     if "%1" == "Second" goto findGSDL
    19         command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
    20         goto done
    21 
    22 :findGSDL
    23 echo.
    24 if "%SERVERLANG%" == "en" echo Greenstone3 Server
    25 if "%SERVERLANG%" == "en" echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
    26 if "%SERVERLANG%" == "en" echo This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
    27 if "%SERVERLANG%" == "en" echo This is free software, and you are welcome to redistribute it
    28 
    29 echo.
    308::  ---- Determine GSDL3HOME ----
     9:: Some users may set the above line manually
    3110set GSDL3PATH=
    3211
    33 :: Some users may set the above line manually
    34  if not "%GSDL3PATH%" == "" goto prepGSDL
     12:: The default location is the current directory
     13 if "%GSDL3PATH%" == "" set GSDL3PATH=.
    3514
    36  :: The default location is the current directory
    37  set GSDL3PATH=.
     15:: Setup Greenstone, unless it has already been done
     16if "%GSDL3SRCHOME%" == "" call "%GSDL3PATH%\gs3-setup.bat" SetEnv > nul
    3817
    39  :: If it is set, use the GSDLHOME environment variable
    40   if "%GSDL3SRCHOME%" == "" goto prepGSDL
    41   set GSDL3PATH=%GSDL3SRCHOME%
    42 
    43 :prepGSDL
    44 :: Setup Greenstone, unless it has already been done
    45 if not "%GSDL3SRCHOME%" == "" goto doneGSDL
    46    call "%GSDL3PATH%\gs3-setup.bat" SetEnv > nul
    47 
    48 :doneGSDL
    49 :: GSDL3PATH is no longer needed, since GSDL3SRCHOME should now be set
    5018set GSDL3PATH=
    5119
    52 :findJava
    53 :: ---- Check Java exists ----
    54 set JAVAPATH=
     20"%RUNJAVA%" -cp "%CLASSPATH%" org.greenstone.server.Server "%GSDL3SRCHOME%"
    5521
    56 :: Some users may set the above line manually
    57 if not "%JAVAPATH%" == "" goto testJava
    5822
    59 :: If it is set, use the JAVA_HOME environment variable
    60  if not "%JAVA_HOME%" == "" goto javahome
    6123
    62 :: Check if Java is on the search path
    63  echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
    64  call setjava.bat
    65  del setjava.bat
    66  if not "%JAVAPATH%" == "" goto testJava
    67 
    68     :: Still haven't found anything, so try looking in the registry (gulp!)
    69     type nul > jdk.reg
    70     regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
    71     type jdk.reg > jdk.txt
    72     del jdk.reg
    73     type nul > jre.reg
    74     regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
    75     type jre.reg > jre.txt
    76     del jre.reg
    77 
    78     winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
    79     del jdk.txt
    80     del jre.txt
    81     call setjava.bat
    82     del setjava.bat
    83 
    84    :: If nothing was found in the registry, we're stuck
    85    if "%JAVAPATH%" == "" goto noJava
    86 
    87    set JAVAPATH=%JAVAPATH%\bin
    88    goto testJava
    89 
    90 :javahome
    91     set JAVAPATH=%JAVA_HOME%\bin
    92 
    93 :testJava
    94 :: Check that a Java executable has been found
    95   if "%SERVERLANG%" == "en" echo Checking Java: %JAVAPATH%
    96   if "%SERVERLANG%" == "es" echo Revisando Java: %JAVAPATH%
    97   if "%SERVERLANG%" == "fr" echo V‚rification de Java: %JAVAPATH%
    98   if "%SERVERLANG%" == "ru" echo à®¢¥àª  Java: %JAVAPATH%
    99   if exist "%JAVAPATH%\java.exe" goto checkServer
    100 
    101 :noJava
    102  echo.
    103     if "%SERVERLANG%" == "en" echo Failed to locate an appropriate version of Java. You must install a
    104     if "%SERVERLANG%" == "en" echo Java Runtime Environment (version 1.4 or greater) before running the
    105     if "%SERVERLANG%" == "en" echo Greenstone3 Server.
    106     goto exit
    107 
    108 :checkServer
    109 ::---- Check that the server program has been compiled ----
    110 if exist "server.jar" goto runServer
    111 if "%SERVERLANG%" == "en" echo "You need to compile the code before running the server"
    112 goto exit
    113 
    114 :runServer
    115 echo Running the Greenstone Server
    116 :: -Xms32M          To set minimum memory
    117 :: -Xmx32M          To set maximum memory
    118 :: -verbose:gc      To set garbage collection messages
    119 :: -Xincgc          For incremental garbage collection
    120 :: -Xprof           Function call profiling
    121 :: -Xloggc:<file>   Write garbage collection log
    122 
    123 "%JAVAPATH%\java" -cp "%CLASSPATH%" org.greenstone.server.Server "%GSDL3SRCHOME%"
    124 
    125 :exit
    126 
    127 :done
    128 :: ---- Clean up ----
    129 set JAVAPATH=
    13024
    13125 
Note: See TracChangeset for help on using the changeset viewer.