代码拉取完成,页面将自动刷新
rem script for locating a valid JRE
rem designed for use by dbviscmd.bat and dbvisgui.bat
rem inspects %JAVA_EXEC%, dbvis installation folder and %PATH% for a JRE and checks that the version is OK
rem returns the executable command (quoted) and the version number on stdout, separated by *
rem
rem NOTE: Modifies environment variables - caller is expected to run with 'setlocal'!
rem
rem Example usage:
rem for /f "delims=* tokens=1-2" %%a in ('reolveJRE.bat') do (
rem set JAVA_EXEC=%%a
rem set JAVA_MAJOR_VERSION=%%b
rem )
rem ----------------------------------------------------------------------------
rem init
rem ----------------------------------------------------------------------------
set DBVIS_HOME=%~dp0
set MIN_VERSION=8
rem check parameters and variables
if NOT "%~1" == "" goto READ_P1
if defined JAVA_EXEC goto READ_ENV
goto FIND_JAVA
rem ----------------------------------------------------------------------------
rem RESOLVE JRE
rem ----------------------------------------------------------------------------
rem resolve which JRE to use
:FIND_JAVA
rem no parameters given, try to locate a JRE
if not defined JAVA_EXEC (
set MY_JAVA=java
set JAVA_EXEC=java
if exist "%DBVIS_HOME%\jre\bin\java.exe" (
cd /d "%DBVIS_HOME%\jre\bin"
set JAVA_EXEC="%DBVIS_HOME%\jre\bin\java.exe"
)
)
goto EXTRACT
:READ_ENV
rem we found a JRE in environment variables
rem we don't know if it's quoted or not, so we do a recursive call with the variable as command line argument
rem (we can strip quotes and handle paths on positional parameters, but not on environment variables)
%0 %JAVA_EXEC%
:READ_P1
rem A JRE was given as parameter to the script.
rem An unquoted path with spaces is interpreted as many parameters, we need to fix this:
rem if parameter 1 is not quoted do a recursive call with all params quoted
if %1==%~1 %0 "%*"
rem OK, we have a single quoted parameter - is it a file?
IF "%~dpnx1" == %1 GOTO READ_P1_FILE
IF "%~pnx1" == %1 GOTO READ_P1_FILE
GOTO READ_P1_COMMAND
:READ_P1_COMMAND
rem Parameter is not a file. Is it an executable command?
where %1 >NUL 2>&1
if errorlevel 1 echo Using environment variable JAVA_EXEC: No such command: [%1] && GOTO ERROR
rem all good:
rem set JAVA_EXEC as the quoted path, cd into the directory and set java as a local command (unquoted)
set JAVA_EXEC=%1
cd /d "%~dp1" >NUL
set MY_JAVA=%~nx1
goto EXTRACT
:READ_P1_FILE
rem Parameter 1 is a file argument. Does it exist?
IF NOT EXIST %1 echo Using environment variable JAVA_EXEC: No such file: [%1] && goto ERROR
rem set JAVA_EXEC as the quoted path, cd into the directory and set java as a local command (unquoted)
set JAVA_EXEC=%1
cd /d "%~dp1" >NUL
set MY_JAVA=%~nx1
goto EXTRACT
rem ----------------------------------------------------------------------------
rem EXTRACT VERSION
rem ----------------------------------------------------------------------------
:EXTRACT
rem Extract the version string
for /f "tokens=3" %%g in ('%MY_JAVA% -version 2^>^&1 ^| findstr /i "version"') do (
set VERSION_STRING=%%g
)
rem Check that version was understood
if defined VERSION_STRING if NOT [%VERSION_STRING%]==[""] goto PARSE
echo Unable to extract java version from [%JAVA_EXEC%]
goto ERROR
:PARSE
rem Remove the double-quotes
set VERSION_STRING=%VERSION_STRING:"=%
rem Extract second number (x) if we are "1.x.y" and first number if not (E.g. 9.0, 10.0)
for /f "delims=. tokens=1-3" %%v in ("%VERSION_STRING%") do (
if /I "%%v" EQU "1" (
set JAVA_MAJOR_VERSION=%%w
) else (
set JAVA_MAJOR_VERSION=%%v
)
)
:CHECK
rem check version
if /I %JAVA_MAJOR_VERSION% LSS %MIN_VERSION% (
echo Java version %VERSION_STRING% is not supported. At least Java %MIN_VERSION% is required.
goto ERROR
)
GOTO OK
rem ----------------------------------------------------------------------------
rem EXIT
rem ----------------------------------------------------------------------------
:ERROR
rem exit with an error level after having echoed the error string on stdout
exit /B 1
:OK
rem exit with an ok error level after having set JAVA_EXEC and JAVA_MAJOR_VERSION variables
exit /B 0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。