E:\>systeminfo | findstr /c:"OS Name" OS Name: Microsoft(R) Windows(R) Server 2003, Enterprise Edition |
E:\>java -version java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode, sharing) |
E:\>test.bat Testing: -Xmx1000m OK Testing: -Xmx1100m OK Testing: -Xmx1200m OK Testing: -Xmx1300m OK Testing: -Xmx1400m OK Testing: -Xmx1400m OK Testing: -Xmx1410m OK Testing: -Xmx1420m OK Testing: -Xmx1430m OK Testing: -Xmx1440m OK Testing: -Xmx1440m OK Final value is: -Xmx1440m Press any key to continue . . . |
复制代码
- @echo off
- REM ============================================================================
- REM Function: Fetch the max value of java option -Xmx in 32 bit Windows system
- REM Version: 1.0 @ Sep 10 2014
- REM ============================================================================
- java -version >nul 2>&1
- if errorlevel 1 (
- echo Please make sure you have:
- echo 1. Installed JDK or JRE
- echo 2. Created environment variable %%JAVA_HOME%%
- echo 3. Added environment variable %%JAVA_HOME%%\bin into %%PATH%%
- goto End
- )
- :StepHundred
- for /l %%i in (1000,100,2048) do (
- java -Xmx%%im -version >nul 2>&1
- if errorlevel 1 (
- goto StepTen
- ) else (
- set "Xmx=%%i"
- echo Testing: -Xmx%%im OK
- )
- )
- :StepTen
- for /l %%i in (%Xmx%,10,2048) do (
- java -Xmx%%im -version >nul 2>&1
- if errorlevel 1 (
- goto StepOne
- ) else (
- set "Xmx=%%i"
- echo Testing: -Xmx%%im OK
- )
- )
- :StepOne
- for /l %%i in (%Xmx%,1,2048) do (
- java -Xmx%%im -version >nul 2>&1
- if errorlevel 1 (
- goto ShowResult
- ) else (
- set "Xmx=%%i"
- echo Testing: -Xmx%%im OK
- )
- )
- :ShowResult
- echo Final value is: -Xmx%Xmx%m
- :End
- pause
欢迎光临 批处理之家 (http://bathome.net./) | Powered by Discuz! 7.2 |