[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[其他] Windows批处理BAT脚本获取32位系统支持的Java参数Xmx的最大值

操作系统版本:
E:\>systeminfo | findstr /c:"OS Name"
OS Name:                   Microsoft(R) Windows(R) Server 2003, Enterprise Edition


Java 版本:
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 . . .


代码:
  1. @echo off
  2. REM ============================================================================
  3. REM Function: Fetch the max value of java option -Xmx in 32 bit Windows system
  4. REM Version: 1.0 @ Sep 10 2014
  5. REM ============================================================================
  6. java -version >nul 2>&1
  7. if errorlevel 1 (
  8.     echo Please make sure you have:
  9.     echo 1. Installed JDK or JRE
  10.     echo 2. Created environment variable %%JAVA_HOME%%
  11.     echo 3. Added environment variable %%JAVA_HOME%%\bin into %%PATH%%
  12.     goto End
  13. )
  14. :StepHundred
  15. for /l %%i in (1000,100,2048) do (
  16.     java -Xmx%%im -version >nul 2>&1
  17.     if errorlevel 1 (
  18.         goto StepTen
  19.     ) else (
  20.         set "Xmx=%%i"
  21.         echo Testing: -Xmx%%im OK
  22.     )
  23. )
  24. :StepTen
  25. for /l %%i in (%Xmx%,10,2048) do (
  26.     java -Xmx%%im -version >nul 2>&1
  27.     if errorlevel 1 (
  28.         goto StepOne
  29.     ) else (
  30.         set "Xmx=%%i"
  31.         echo Testing: -Xmx%%im OK
  32.     )
  33. )
  34. :StepOne
  35. for /l %%i in (%Xmx%,1,2048) do (
  36.     java -Xmx%%im -version >nul 2>&1
  37.     if errorlevel 1 (
  38.         goto ShowResult
  39.     ) else (
  40.         set "Xmx=%%i"
  41.         echo Testing: -Xmx%%im OK
  42.     )
  43. )
  44. :ShowResult
  45. echo Final value is: -Xmx%Xmx%m
  46. :End
  47. pause
复制代码

顶,很不错

TOP

返回列表