buildSettings.bat 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. :: Licensed Materials - Property of IBM
  2. :: BI and PM: Mobile
  3. :: (C) Copyright IBM Corp. 2007, 2013
  4. :: US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. @echo off
  6. rem ---------------------------------------------------------------------------
  7. rem Shell script (Windows) to invoke jre and launch buildSettings tool.
  8. rem
  9. rem J_HOME is the location of the Java RE installation; if JAVA_HOME is
  10. rem defined, use it. Otherwise default to the local distribution.
  11. rem J_OPTS are the Java options to be passed into the JAVA VM (optional)
  12. rem ---------------------------------------------------------------------------
  13. rem If the argument -java:{env | local} is present as first argument then the required JRE will be
  14. rem loaded: -java:env will force the script to look for JRE using JAVA_HOME environment variable.
  15. rem If not found then it will end by an error. The argument -java:local will force it to look
  16. rem for JRE within the local distribution. If not found then it will end by an error.
  17. rem Otherwise, the script will default by looking for a JRE using the JAVA_HOME environment
  18. rem variable, then if cannot find one, it will try to use the local distribution.
  19. rem Causes all changes made to environment variables to be local to this script
  20. rem up to the point where endlocal is encountered.
  21. setlocal
  22. rem Change directories to where this script lives
  23. CD /D %~dp0
  24. rem ----- Verify and Set Required Environment Variables -----------------------
  25. rem check if we need to run the local jre
  26. rem Shift the first argument: -java:local
  27. if "%1" == "-java:local" (shift & goto useLocal)
  28. rem Try first the use of JAVA_HOME
  29. goto useEnvVar
  30. :useEnvVarOnly
  31. rem JAVA_HOME should be defined first.
  32. if "%JAVA_HOME%" == "" goto JavaHomeError
  33. set J_HOME=%JAVA_HOME%
  34. echo Looking for JRE in: %J_HOME%\bin... >&2
  35. if exist "%J_HOME%\bin\java.exe" goto gotJava
  36. set J_HOME=%JAVA_HOME%\jre
  37. echo Looking for JRE in: %J_HOME%\jre\bin... >&2
  38. if exist "%J_HOME%\bin\java.exe" goto gotJava
  39. :JavaHomeError
  40. echo You have specified the argument '-java:env'. >&2
  41. echo However, the environment variable JAVA_HOME is not defined or incorrectly defined. >&2
  42. echo Please define JAVA_HOME first before using the argument '-java:env'. >&2
  43. goto finish
  44. :useLocal
  45. rem Using the local distribution either because -java:local was
  46. rem specified or because the JAVA_HOME environment variable
  47. rem is not defined or if the JAVA_HOME location doesn't have a JRE.
  48. set J_HOME=jre\7.0
  49. echo Looking for JRE in: %J_HOME%\bin... >&2
  50. if exist "%J_HOME%\bin\java.exe" goto gotJava
  51. rem Did not find a JRE in the local location, display error and exit.
  52. goto error
  53. :useEnvVar
  54. rem Shift the first argument: -java:env
  55. if "%1" == "-java:env" (shift & goto useEnvVarOnly)
  56. rem Using the distribution referred by JAVA_HOME because
  57. rem -java:local was NOT specified and the JAVA_HOME environment
  58. rem variable is defined.
  59. set J_HOME=%JAVA_HOME%
  60. echo Looking for JRE in: %J_HOME%\bin... >&2
  61. if exist "%J_HOME%\bin\java.exe" goto gotJava
  62. set J_HOME=%JAVA_HOME%\jre
  63. echo Looking for JRE in: %J_HOME%\bin... >&2
  64. if exist "%J_HOME%\bin\java.exe" goto gotJava
  65. rem Did not find a JRE in the environment variable's location. If the
  66. rem -java:env argument was not specified, try the local distribution.
  67. if not "%1" == "-java:env" goto useLocal
  68. :error
  69. echo Could not find a JRE. Cannot run buildSettings.
  70. goto finish
  71. :gotJava
  72. rem ----- Prepare Appropriate Java Execution Commands -------------------------
  73. set _RUNJAVA="%J_HOME%\bin\java"
  74. rem ----- Disabling DirectDraw. ----------------------------------------------
  75. rem The next command checks if the DirectDraw will be disabled.
  76. rem Disabling this DirectDraw might reduce the performance of the program that renders the image.
  77. rem It is recommended to disable the DirectDraw in the case the ConfigTool and some desktop
  78. rem icons flicker/flashes when started.
  79. if "%1" == "-noddraw" set DD_OPTS=-Dsun.java2d.noddraw=true
  80. if "%1" == "-noDDraw" set DD_OPTS=-Dsun.java2d.noddraw=true
  81. if not "%DD_OPTS%" == "" echo Disabling DirectDraw...
  82. set J_OPTS=%DD_OPTS% %J_OPTS%
  83. rem ----- Set Up The Runtime Classpath ----------------------------------------
  84. set CP=mobadmin.jar
  85. rem ----- Execute The Requested Command ---------------------------------------
  86. %_RUNJAVA% -cp %CP% %J_OPTS% com.cognos.mobile.consoleclient.MobAdmin %*
  87. :finish
  88. endlocal