mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
07.41.2009 c4d533f5baf253f8560026fde7d9294a6f0a2091
Fix for issue 3971 (windows: setup should detect Java automatically)
The fix will improve the user experience in Windows when installing from a ZIP file. When the JVM is installed, the java.exe is contained in the PATH environment variable. The fix consists on trying to see if java.exe is on the PATH by calling java.exe -version if no OPENDS_JAVA_HOME nor JAVA_HOME environment variables are defined..

Note that even though this is an expensive operation in term of resources, this will only be called when the setup is launched for the first time. The setup will update the environment of execution of OpenDS and this call will no longer be made. The exception to this is the case where the user removes all the environment by deleting the files generated by the setup (or dsjavaproperties), this is done usually when the java environment has changed and the user has been told to do so (and also told to call dsjavaproperties). Once dsjavaproperties is called again (the normal procedure to configure the execution environment) this 'extra' call to java.exe will not be made in the scripts.

In other words, the fix will only have a performance penalty when the user calls 'setup' for the first time (and no OPENDS_JAVA_HOME or JAVA_HOME env variables are defined) and when the user resets the execution environment (and so is supposed to call dsjavaproperties). This small penalty (some extra tenths of a second) is acceptable because with the fix in most of the cases the user will not have to set OPENDS_JAVA_HOME (dealing with environment variables is a rare procedure for Windows users). As a result of this the user experience will be much smoother than what is today.
1 files modified
9 ■■■■ changed files
opends/resource/bin/_script-util.bat 9 ●●●● patch | view | raw | blame | history
opends/resource/bin/_script-util.bat
@@ -106,11 +106,18 @@
goto endJavaHomeAndArgs
:checkJavaHome
if "%JAVA_HOME%" == "" goto noJavaFound
if "%JAVA_HOME%" == "" goto checkJavaPath
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaFound
set OPENDS_JAVA_BIN=%JAVA_HOME%\bin\java.exe
goto endJavaHomeAndArgs
:checkJavaPath
java.exe -version > NUL 2>&1
set RESULT_CODE=%errorlevel%
if not %errorlevel% == 0 goto noJavaFound
set OPENDS_JAVA_BIN=java.exe
goto endJavaHomeAndArgs
:noJavaFound
echo ERROR:  Could not find a valid Java binary to be used.
echo You must specify the path to a valid Java 5.0 or higher version.