[r4820]: core / trunk / scripts / oj_windows.bat  Maximize  Restore  History

Download this file

321 lines (269 with data), 11.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
@echo off & setlocal
rem call :init
rem -- Save current working dir and OJ home --
set OLD_DIR=%CD%
set JUMP_HOME=%~dp0..%
rem -- uncomment to save settings and log to user profile ---
rem -- defaults to 'JUMP_HOME', if former is not writable 'userprofile/.openjump' --
rem set SETTINGS_HOME="%HOMEDRIVE%%HOMEPATH%"\.openjump
rem -- uncomment to manually set java home --
rem set JAVA_HOME=G:\path\to\a\specific\<jre|jdk>-1.<5|6>
rem -- uncomment to use 'java' for console output, if unset defaults to 'javaw' for background jre --
rem set JAVA_BIN=java
rem -- set some java runtime options here, initialize empty --
set JAVA_OPTS=
rem --- uncomment and change your language/country here to overwrite OS locale setting ---
rem set JAVA_OPTS=%JAVA_OPTS% -Duser.language=de -Duser.country=DE
rem --- enforce a memory configuration here, default value is the ---
rem --- size of ram or 1GB for 32bit jre's, whichever is bigger ---
rem --- Xms is initial size, Xmx is maximum size, values ---
rem --- are ##M for ## Megabytes, ##G for ## Gigabytes ---
rem set JAVA_MEM=-Xms64M -Xmx512M
rem --- uncomment and change your http proxy settings here
rem set JAVA_OPTS=%JAVA_OPTS% -Dhttp.proxyHost=myproxyserver.com -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts="localhost|host.mydomain.com"
rem --- if the proxy server requires authentication uncomment and edit also these
rem set JAVA_OPTS=%JAVA_OPTS% -Dhttp.proxyUser=username -Dhttp.proxyPass=password
rem -- dequote path entries, just to be sure --
call :dequote %PATH%
set "PATH=%unquoted%"
rem -- dequote java_home, later on we assume it's unquoted --
call :dequote %JAVA_HOME%
set "JAVA_HOME=%unquoted%"
rem -- find java runtime --
set JAVA=
rem --- default to javaw ---
if "%JAVA_BIN%"=="" set JAVA_BIN=javaw
rem --- search binary in path ---
@for %%i in (%JAVA_BIN%.exe) do @if NOT "%%~$PATH:i"=="" set JAVA=%%~$PATH:i
rem --- we might be on amd64 having only x86 jre installed ---
if "%JAVA%"=="" if DEFINED ProgramFiles(x86) if NOT "%PROCESSOR_ARCHITECTURE%"=="x86" (
rem --- restart the batch in x86 mode---
echo Warning: No java interpreter found in path.
echo Retry using Wow64 filesystem [32bit environment] redirection.
%SystemRoot%\SysWOW64\cmd.exe /c %0 %*
exit /b %ERRORLEVEL%
)
rem --- if unset fall back to plain bin name, just in case ---
if "%JAVA%"=="" set JAVA=%JAVA_BIN%
rem --- java home definition overwrites all ---
if NOT "%JAVA_HOME%"=="" set "JAVA=%JAVA_HOME%\bin\%JAVA_BIN%"
rem -- show java version (for debugging) --
for %%F in ("%JAVA%") do set "dirname=%%~dpF"
echo Using '%JAVA_BIN%' found in '%dirname%'
rem "%dirname%java" -version
SET concat=
for /f "tokens=* delims=" %%i in ('"%dirname%java" -version 2^>^&1') do call :concat "; " %%i
set "JAVA_VERSIONSTRING=%concat%"
echo %JAVA_VERSIONSTRING%
rem -- detect if java is 64bit --
for /f "delims=" %%v in ('echo "%JAVA_VERSIONSTRING%"^|findstr /I "64-Bit"') do (
set JAVA_X64=64
)
rem -- Change to jump home dir --
rem -- NOTE: mount UNC paths to a local drive for this --
cd /D "%JUMP_HOME%"
rem -- Uninstall if asked nicely ---
if "%1"=="--uninstall" (
"%JAVA%" -jar .\uninstall\uninstaller.jar
goto:eof
)
set LIB=lib
rem -- setup native lib paths
set NATIVE=%LIB%\native
if DEFINED ProgramFiles(x86) set X64=64
if DEFINED JAVA_X64 (
set "JAVA_ARCH=x64"
) else (
set "JAVA_ARCH=x86"
)
rem command ver example outputs
rem german win7 "Microsoft Windows [Version 6.1.7601]"
rem finnish xp "Microsoft Windows XP [versio 5.1.2600]"
rem french xp "Microsoft Windows XP [version 5.1.2600]"
rem --- XP Version 5.x ---
for /f "delims=" %%v in ('ver^|findstr /REC:" 5[0-9\.]*]"') do (
set "ID=xp"
)
rem --- Vista Version 6.0 ---
for /f "delims=" %%v in ('ver^|findstr /REC:" 6.0.[0-9\.]*]"') do (
set "ID=vista"
)
rem --- 7 Version 6.1 ---
for /f "delims=" %%v in ('ver^|findstr /REC:" 6.1.[0-9\.]*]"') do (
set "ID=seven"
)
rem --- 8 Version 6.2 ---
for /f "delims=" %%v in ('ver^|findstr /REC:" 6.2.[0-9\.]*]"') do (
set "ID=eight"
)
rem --- 8.1 Version 6.3 ---
for /f "delims=" %%v in ('ver^|findstr /REC:" 6.3.[0-9\.]*]"') do (
set "ID=eightone"
)
rem -- add native as fallthrough and lib\ext the legacy value and default system path --
if DEFINED X64 (
set "NATIVEPATH=%NATIVE%\%ID%%X64%-%JAVA_ARCH%;%NATIVE%\%ID%%X64%"
set NATIVE64CLASSPATHS="%NATIVE%\%ID%%X64%-%JAVA_ARCH%\*.jar" "%NATIVE%\%ID%%X64%\*.jar"
)
set "NATIVEPATH=%NATIVEPATH%;%NATIVE%\%ID%-%JAVA_ARCH%;%NATIVE%\%ID%"
set "NATIVEPATH=%NATIVEPATH%;%NATIVE%\%JAVA_ARCH%"
set "PATH=%NATIVEPATH%;%NATIVE%;%LIB%\ext;%PATH%"
rem -- debug info --
if /i NOT "%JAVA_BIN%"=="javaw" echo ---PATH--- & echo %PATH%
rem -- set classpath --
set CLASSPATH=.;bin;conf
rem -- add jars to classpath --
for %%i in (
"%LIB%\*.jar" "%LIB%\*.zip" "%LIB%\imageio-ext\*.jar"
%NATIVE64CLASSPATHS%
"%NATIVE%\%ID%-%JAVA_ARCH%\*.jar" "%NATIVE%\%ID%\*.jar"
"%NATIVE%\%JAVA_ARCH%\*.jar" "%NATIVE%\*.jar"
) do (
set jarfile=%%i
rem If we append to a variable inside the for, only the last entry will
rem be kept. So append to the variable outside the for.
rem See http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20561701.html.
rem [Jon Aquino]
call :setclass
)
rem -- set GDAL vars --
if DEFINED JAVA_X64 (
set "GDAL_FOLDER=gdal-win-x64"
) else (
set "GDAL_FOLDER=gdal-win-x86"
)
set "GDAL_FOLDER=lib\native\%GDAL_FOLDER%"
if EXIST "%GDAL_FOLDER%" (
set "GDAL_DATA=%GDAL_FOLDER%\bin\gdal-data"
set "GDAL_DRIVER_PATH=%GDAL_FOLDER%\bin\gdal\plugins"
set "PATH=%GDAL_FOLDER%\bin;%GDAL_FOLDER%\bin\gdal\java;%PATH%"
rem --- gdal binding is version specific, prioritize the one delivered with native libs ---
set "CLASSPATH=%GDAL_FOLDER%\bin\gdal\java\gdal.jar;%CLASSPATH%"
)
rem -- debug info --
if /i NOT "%JAVA_BIN%"=="javaw" echo ---CLASSPATH--- & echo %CLASSPATH%
rem -- set settings home/log dir if none given --
rem --- dequote settings_home, later on we assume it's unquoted ---
call :dequote %SETTINGS_HOME%
set "SETTINGS_HOME=%unquoted%"
rem --- set default or create missing folder ---
rem --- ATTENTION: logdir requires a trailing backslash for concatenation in log4j.xml ---
if NOT DEFINED SETTINGS_HOME (
rem ---- check if jumphome is writable ----
copy /Y NUL "%JUMP_HOME%\.writable" > NUL 2>&1 && set WRITEOK=1
if DEFINED WRITEOK (
rem ---- an absolute settings_home allows file:/// for log4j conf ----
set "SETTINGS_HOME=%JUMP_HOME%"
) else (
set "SETTINGS_HOME=%HOMEDRIVE%%HOMEPATH%\.openjump"
)
)
set "LOG_DIR=%SETTINGS_HOME%/"
rem -- debug info --
if /i NOT "%JAVA_BIN%"=="javaw" echo ---Save logs ^& state to--- & echo %SETTINGS_HOME%
rem --- create folder if not existing ---
if NOT EXIST "%SETTINGS_HOME%" mkdir "%SETTINGS_HOME%"
rem -- look if we have a custom logging configuration in settings --
if EXIST "%SETTINGS_HOME%\log4j.xml" (
rem --- log4j can't seem to find absolute path without the file:/// prefix ---
set "LOG4J_CONF=file:///%SETTINGS_HOME%\log4j.xml"
) else (
set LOG4J_CONF=.\bin\log4j.xml
)
rem -- add memory settings --
if NOT DEFINED JAVA_MEM (
call :memory
)
rem -- essential options, don't change unless you know what you're doing --
set JAVA_OPTS=%JAVA_OPTS% -Dlog4j.configuration="%LOG4J_CONF%" -Dlog.dir="%LOG_DIR%" -Djump.home="%JUMP_HOME%" %JAVA_MEM%
rem -- set default app options --
set JUMP_OPTS=-default-plugins bin\default-plugins.xml -state "%SETTINGS_HOME%" -plug-in-directory "%LIB%\ext"
rem --- workbench-properties.xml is used to manually load plugins (ISA uses this) ---
if EXIST "bin\workbench-properties.xml" set "JUMP_OPTS=%JUMP_OPTS% -properties bin\workbench-properties.xml"
rem -- disconnect javaw from console by using start --
rem -- note: title is needed or start won't accept quoted path to java binary (protect spaces in javapath) --
if /i "%JAVA_BIN%"=="javaw" ( set START=start "" ) else ( set START= )
if /i NOT "%JAVA_BIN%"=="javaw" echo ---Start OJ---
%START% "%JAVA%" -cp "%CLASSPATH%" %JAVA_OPTS% com.vividsolutions.jump.workbench.JUMPWorkbench %JUMP_OPTS% %*
cd /D %OLD_DIR%
rem -- give user a chance to see console output if we are in console mode but the app finished already
if /i NOT "%JAVA_BIN%"=="javaw" pause
goto:eof
:init
rem --- reset variables ---
set JAVA=
set JAVA_MEM=
set JAVA_BIN=
set SETTINGS_HOME=
goto:eof
:setclass
set "CLASSPATH=%CLASSPATH%;%jarfile%"
set jarfile=
goto:eof
:dequote
SETLOCAL enabledelayedexpansion
set string=%*
if DEFINED string set string=!string:"=!
ENDLOCAL & set unquoted=%string%
goto:eof
:concat
set "glue=%~1"
shift
set string=
:loop
set glue2=
if DEFINED string set "glue2= "
if NOT [%1]==[] (
set "string=%string%%glue2%%1"
shift
goto :loop
)
if NOT "%concat%" == "" (
set "string=%glue%%string%"
)
set "concat=%concat%%string%"
goto:eof
:memory
if /i NOT "%JAVA_BIN%"=="javaw" echo ---Detect maximum memory limit---
rem --- default java32 limit is 1GB ---
set /a "JAVA_XMX_X86=1024*1024"
rem --- detect ram size, values are in kB ---
for /f "delims=" %%l in ('wmic os get FreePhysicalMemory^,TotalVisibleMemorySize /format:list') do >nul 2>&1 set "OS_%%l"
if NOT DEFINED OS_TotalVisibleMemorySize goto mem_failed
rem --- use 100% of ram as default limit (1.124 is a factor to make java64 really use that much) ---
set /a "JAVA_XMX=%OS_TotalVisibleMemorySize%/1000*1124"
set /a "JAVA_RAM_QUARTER=%OS_TotalVisibleMemorySize%/4"
rem --- a. cap to 1GB for 32bit jre ---
rem --- b. use xmx value if it fits into free space ---
rem --- c. use freemem value if bigger than 1/4 ram (jre default) ---
rem --- d. don't set, use jre default (works even though less than 1/4 ram might be free) ---
if NOT DEFINED JAVA_X64 if %JAVA_XMX% GTR %JAVA_XMX_X86% goto use_cap
goto use_max
rem if %OS_FreePhysicalMemory% GEQ %JAVA_XMX%
rem if %OS_FreePhysicalMemory% GTR %JAVA_RAM_QUARTER% goto :use_free
rem if /i NOT "%JAVA_BIN%"=="javaw" echo Less than 1/4 ram free. Use jre default.
goto:eof
:use_cap
rem --- if x86 cap is bigger than actual ram, use ram size instead ---
if %JAVA_XMX_X86% GTR %OS_TotalVisibleMemorySize% call :use_max
call :xmx %JAVA_XMX_X86%
if /i NOT "%JAVA_BIN%"=="javaw" echo set %JAVA_MEM_STRING% ^(32 bit jre maximum^)
goto:eof
:use_max
call :xmx %JAVA_XMX%
if /i NOT "%JAVA_BIN%"=="javaw" echo set %JAVA_MEM_STRING% ^(ram maximum^)
goto:eof
:use_free
call :xmx %OS_FreePhysicalMemory%
if /i NOT "%JAVA_BIN%"=="javaw" call echo set %JAVA_MEM_STRING% ^(free memory^)
goto:eof
:mem_failed
if /i NOT "%JAVA_BIN%"=="javaw" call echo skipped because: Couldn't determine ram size. Use safe 1GB value.
call :xmx %JAVA_XMX_X86%
goto:eof
:xmx
set /a "value=%1/1024"
set JAVA_MEM=-Xmx%value%M
set "JAVA_MEM_STRING=Xmx to %value%M"
goto:eof
:eof