source: greenstone3/trunk/gs3-setup.bat@ 15050

Last change on this file since 15050 was 15050, checked in by oranfry, 14 years ago

create the gs2build/lib directory before trying to export to it

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1@echo off
2
3::get user defined environment variable
4set JRE_HOME=
5set JAVA_HOME=
6set CLASSPATH=
7
8if exist gs3-setup.bat goto start
9 echo This script must be run from within the Greenstone 3 home directory
10 goto exit
11
12:start
13:: ---- Set the GSDL3HOME variable to the current directory ----
14cd | winutil\setvar.exe GSDL3SRCHOME > %SystemDir%setgsdl3.bat
15call setgsdl3.bat
16del setgsdl3.bat
17echo GSDL3SRCHOME: %GSDL3SRCHOME%
18set GSDL3HOME=%GSDL3SRCHOME%\web
19echo GSDL3HOME: %GSDL3HOME%
20
21:: change if using external tomcat
22set TOMCAT_HOME=%GSDL3SRCHOME%\packages\tomcat
23
24:: ---- Set other important environment variables ----
25set GSDLOS=windows
26set PATH=%PATH%;%GSDL3SRCHOME%\bin;%GSDL3SRCHOME%\bin\script;%GSDL3SRCHOME%\lib\jni;
27
28:: ---- Set the CLASSPATH environment variable ----
29set CLASSPATH=.;%GSDL3HOME%\WEB-INF\classes;%GSDL3SRCHOME%\resources\java;%CLASSPATH%
30if exist setcp.bat del setcp.bat
31for %%j in ("%GSDL3SRCHOME%"\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
32for %%j in ("%GSDL3HOME%"\WEB-INF\lib\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
33for %%j in ("%GSDL3SRCHOME%"\lib\jni\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
34for %%j in ("%TOMCAT_HOME%"\common\endorsed\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
35for %%j in ("%GSDL3SRCHOME%"\build\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
36
37call setcp.bat
38del setcp.bat
39
40goto findJREHOME
41
42:: ---- Check JRE_HOME ----
43:findJREHOME
44if not "%JRE_HOME%" == "" goto testJREHOME
45 goto findJREHOME2
46
47::---- try JREHOME ----
48:findJREHOME2
49if "%JREHOME%" == "" goto findJAVAHOME
50 set JRE_HOME=%JREHOME%
51 testJREHOME
52
53::test JRE_HOME is set correctly
54:testJREHOME
55if exist "%JRE_HOME%\bin\java.exe" goto gotJREHOME
56 echo JRE_HOME: "%JRE_HOME%"
57 echo Couldn't find "%JRE_HOME%\bin\java.exe"
58 echo The JRE_HOME environment variable is not defined correctly
59 echo This environment variable is needed to run this program
60 goto pauseANdExit
61
62
63::set the RUNJAVA and exit
64:gotJREHOME
65 set RUNJAVA=%JRE_HOME%\bin\java.exe
66 set PATH=%JRE_HOME%\bin;%PATH%
67 echo JRE_HOME: "%JRE_HOME%"
68 echo Your environment has successfully been set up to run Greenstone3
69 goto exit
70
71
72:: ---- check JAVA_HOME ----
73:findJAVAHOME
74if not "%JAVA_HOME%" == "" goto testJAVAHOME
75 goto findJAVAHOME2
76
77
78::---- check JAVAHOME ----
79:findJAVAHOME2
80if "%JAVAHOME%" == "" goto noJAVAHOME
81 set JAVA_HOME=%JAVAHOME%
82 testJAVAHOME
83
84
85:: test JAVA_HOME is set Correctly
86:testJAVAHOME
87if not exist "%JAVA_HOME%\bin\java.exe" goto wrongJAVAHOME
88if not exist "%JAVA_HOME%\bin\javac.exe" goto wrongJAVAHOME2
89goto gotJAVAHOME
90
91
92:wrongJAVAHOME
93echo JAVA_HOME: "%JAVA_HOME%"
94echo Couldn't find "%JAVA_HOME%\bin\java.exe"
95echo The JAVA_HOME environment variable is not defined correctly
96echo This environment variable is needed to run this program
97goto pauseANdExit
98
99:wrongJAVAHOME2
100echo JAVA_HOME: "%JAVA_HOME%"
101echo Couldn't find "%JAVA_HOME%\bin\javac.exe"
102echo The JAVA_HOME environment variable is not defined correctly
103echo This environment variable is needed to run this program
104echo NB: JAVA_HOME should point to a JDK not a JRE
105goto pauseANdExit
106
107::set the RUNJAVA and exit
108:gotJAVAHOME
109 set RUNJAVA=%JAVA_HOME%\bin\java.exe
110 set PATH=%JAVA_HOME%\bin;%PATH%
111 echo JAVA_HOME: "%JAVA_HOME%"
112 echo Your environment has successfully been set up to run Greenstone3
113 goto exit
114
115::try find java on the search path
116:noJAVAHOME
117:: Check if Java is on the search path
118 echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
119 call setjava.bat
120 del setjava.bat
121
122if exist "%JAVAPATH%\bin\java.exe" goto gotJava
123 :: Still haven't found anything, so try looking in the registry (gulp!)
124 type nul > jdk.reg
125 regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
126 type jdk.reg > jdk.txt
127 del jdk.reg
128 type nul > jre.reg
129 regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
130 type jre.reg > jre.txt
131 del jre.reg
132
133 winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
134 del jdk.txt
135 del jre.txt
136 call setjava.bat
137 del setjava.bat
138
139 :: If nothing was found in the registry, we're stuck
140 if "%JAVAPATH%" == "" goto noJava
141 goto gotJava
142
143:gotJava
144 set JRE_HOME=%JAVAPATH%
145 goto testJREHOME
146
147
148:noJava
149 echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
150 echo At least one of these environment variable is needed to run Greenstone3
151 echo You must install a Java Run Environment (version 1.4 or greater)
152 echo and set the JRE_HOME environment variable before running the
153 echo Greenstone 3 Digital Library Software.
154 pause
155 goto exit
156
157:pauseAndExit
158 pause
159 goto exit
160
161:exit
162
163
164
Note: See TracBrowser for help on using the repository browser.