2976N/A@echo off
2976N/Arem CDDL HEADER START
2976N/Arem
2976N/Arem The contents of this file are subject to the terms of the
2976N/Arem Common Development and Distribution License, Version 1.0 only
2976N/Arem (the "License"). You may not use this file except in compliance
2976N/Arem with the License.
2976N/Arem
6983N/Arem You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
6983N/Arem or http://forgerock.org/license/CDDLv1.0.html.
2976N/Arem See the License for the specific language governing permissions
2976N/Arem and limitations under the License.
2976N/Arem
2976N/Arem When distributing Covered Code, include this CDDL HEADER in each
6983N/Arem file and include the License file at legal-notices/CDDLv1_0.txt.
6983N/Arem If applicable, add the following below this CDDL HEADER, with the
6983N/Arem fields enclosed by brackets "[]" replaced with your own identifying
6983N/Arem information:
2976N/Arem Portions Copyright [yyyy] [name of copyright owner]
2976N/Arem
2976N/Arem CDDL HEADER END
2976N/Arem
2976N/Arem
5022N/Arem Copyright 2008-2010 Sun Microsystems, Inc.
6238N/Arem Portions Copyright 2011-2013 ForgeRock AS
2976N/A
2976N/Aset SET_JAVA_HOME_AND_ARGS_DONE=false
2976N/Aset SET_ENVIRONMENT_VARS_DONE=false
2976N/Aset SET_CLASSPATH_DONE=false
2976N/A
3824N/Aif "%INSTALL_ROOT%" == "" goto setInstanceRoot
2976N/A
2976N/A:scriptBegin
2976N/Aif "%SCRIPT_UTIL_CMD%" == "set-full-environment-and-test-java" goto setFullEnvironmentAndTestJava
2976N/Aif "%SCRIPT_UTIL_CMD%" == "set-full-environment" goto setFullEnvironment
2976N/Aif "%SCRIPT_UTIL_CMD%" == "set-java-home-and-args" goto setJavaHomeAndArgs
2976N/Aif "%SCRIPT_UTIL_CMD%" == "set_environment_vars" goto setEnvironmentVars
2976N/Aif "%SCRIPT_UTIL_CMD%" == "test-java" goto testJava
2976N/Aif "%SCRIPT_UTIL_CMD%" == "set-classpath" goto setClassPath
6238N/Agoto end
2976N/A
2976N/A:setInstanceRoot
2976N/Asetlocal
2976N/Afor %%i in (%~sf0) do set DIR_HOME=%%~dPsi..
3824N/Aset INSTALL_ROOT=%DIR_HOME%
3824N/Aset INSTANCE_DIR=
6606N/Aif exist "%INSTALL_ROOT%\instance.loc" (
6606N/A set /p INSTANCE_DIR=<%INSTALL_ROOT%\instance.loc
6606N/A) else (
6606N/Aset INSTANCE_DIR=.
3824N/A)
5728N/Aset CUR_DIR=%CD%
3842N/Acd /d %INSTALL_ROOT%
3842N/Acd /d %INSTANCE_DIR%
3824N/Aset INSTANCE_ROOT=%CD%
3842N/Acd /d %CUR_DIR%
2976N/Agoto scriptBegin
2976N/A
2976N/A:setClassPath
6238N/Aif "%SET_CLASSPATH_DONE%" == "true" goto end
6251N/Arem get the absolute paths before building the classpath
6251N/Arem it also helps comparing the two paths
6251N/AFOR /F %%i IN ("%INSTALL_ROOT%") DO set INSTALL_ROOT=%%~dpnxi
6251N/AFOR /F %%i IN ("%INSTANCE_ROOT%") DO set INSTANCE_ROOT=%%~dpnxi
6258N/Acall "%INSTALL_ROOT%\lib\setcp.bat" %INSTALL_ROOT%\lib\bootstrap.jar
4287N/AFOR %%x in ("%INSTALL_ROOT%\resources\*.jar") DO call "%INSTALL_ROOT%\lib\setcp.bat" %%x
3824N/Aset CLASSPATH=%INSTANCE_ROOT%\classes;%CLASSPATH%
6251N/Aif "%INSTALL_ROOT%" == "%INSTANCE_ROOT%" goto setClassPathDone
6251N/AFOR %%x in ("%INSTANCE_ROOT%\lib\*.jar") DO call "%INSTANCE_ROOT%\lib\setcp.bat" %%x
3824N/A:setClassPathDone
2976N/Aset SET_CLASSPATH_DONE=true
2976N/Agoto scriptBegin
2976N/A
2976N/A:setFullEnvironment
2976N/Aif "%SET_JAVA_HOME_AND_ARGS_DONE%" == "false" goto setJavaHomeAndArgs
2976N/Aif "%SET_CLASSPATH_DONE%" == "false" goto setClassPath
2976N/Aif "%SET_ENVIRONMENT_VARS_DONE%" == "false" goto setEnvironmentVars
6238N/Agoto end
2976N/A
2976N/A:setFullEnvironmentAndTestJava
2976N/Aif "%SET_JAVA_HOME_AND_ARGS_DONE%" == "false" goto setJavaHomeAndArgs
2976N/Aif "%SET_CLASSPATH_DONE%" == "false" goto setClassPath
2976N/Aif "%SET_ENVIRONMENT_VARS_DONE%" == "false" goto setEnvironmentVars
2976N/Agoto testJava
2976N/A
2976N/A
2976N/A:setJavaHomeAndArgs
6238N/Aif "%SET_JAVA_HOME_AND_ARGS_DONE%" == "true" goto end
5022N/Aif not exist "%INSTANCE_ROOT%\lib\set-java-home.bat" goto checkEnvJavaHome
3824N/Acall "%INSTANCE_ROOT%\lib\set-java-home.bat"
5636N/Aif "%OPENDJ_JAVA_BIN%" == "" goto checkEnvJavaHome
2976N/A:endJavaHomeAndArgs
2976N/Aset SET_JAVA_HOME_AND_ARGS_DONE=true
2976N/Agoto scriptBegin
2976N/A
5022N/A:checkEnvJavaHome
5636N/Aif "%OPENDJ_JAVA_BIN%" == "" goto checkEnvLegacyJavaHome
5636N/Aif not exist "%OPENDJ_JAVA_BIN%" goto checkEnvLegacyJavaHome
5636N/Agoto endJavaHomeAndArgs
5636N/A
5636N/A:checkEnvLegacyJavaHome
5636N/Aif "%OPENDS_JAVA_BIN%" == "" goto checkOpenDJJavaHome
5636N/Aif not exist "%OPENDS_JAVA_BIN%" goto checkOpenDJJavaHome
5636N/Aset OPENDJ_JAVA_BIN=%OPENDS_JAVA_BIN%
2976N/Agoto endJavaHomeAndArgs
2976N/A
5636N/A
5636N/A:checkOpenDJJavaHome
5636N/Aif "%OPENDJ_JAVA_HOME%" == "" goto checkLegacyOpenDSJavaHome
5636N/Aif not exist "%OPENDJ_JAVA_HOME%\bin\java.exe" goto checkLegacyOpenDSJavaHome
5636N/Aset OPENDJ_JAVA_BIN=%OPENDJ_JAVA_HOME%\bin\java.exe
5636N/Agoto endJavaHomeAndArgs
5636N/A
5636N/A:checkLegacyOpenDSJavaHome
4915N/Aif "%OPENDS_JAVA_HOME%" == "" goto checkJavaPath
4915N/Aif not exist "%OPENDS_JAVA_HOME%\bin\java.exe" goto checkJavaPath
5636N/Aset OPENDJ_JAVA_BIN=%OPENDS_JAVA_HOME%\bin\java.exe
2976N/Agoto endJavaHomeAndArgs
2976N/A
4915N/A:checkJavaPath
4915N/Ajava.exe -version > NUL 2>&1
4915N/Aif not %errorlevel% == 0 goto checkJavaBin
5636N/Aset OPENDJ_JAVA_BIN=java.exe
4915N/Agoto endJavaHomeAndArgs
4915N/A
2976N/A:checkJavaBin
2976N/Aif "%JAVA_BIN%" == "" goto checkJavaHome
2976N/Aif not exist "%JAVA_BIN%" goto checkJavaHome
5636N/Aset OPENDJ_JAVA_BIN=%JAVA_BIN%
2976N/Agoto endJavaHomeAndArgs
2976N/A
2976N/A:checkJavaHome
4915N/Aif "%JAVA_HOME%" == "" goto noJavaFound
2976N/Aif not exist "%JAVA_HOME%\bin\java.exe" goto noJavaFound
5636N/Aset OPENDJ_JAVA_BIN=%JAVA_HOME%\bin\java.exe
2976N/Agoto endJavaHomeAndArgs
2976N/A
2976N/A:noJavaFound
4261N/Aecho ERROR: Could not find a valid Java binary to be used.
5224N/Aecho You must specify the path to a valid Java 6.0 update 10 or higher version.
2976N/Aecho The procedure to follow is:
2976N/Aecho 1. Delete the file %INSTANCE_ROOT%\lib\set-java-home.bat if it exists.
5636N/Aecho 2. Set the environment variable OPENDJ_JAVA_HOME to the root of a valid
5218N/Aecho Java 6.0 installation.
4261N/Aecho If you want to have specific Java settings for each command line you must
2976N/Aecho follow the steps 3 and 4.
4261N/Aecho 3. Edit the properties file specifying the Java binary and the Java arguments
4261N/Aecho for each command line. The Java properties file is located in:
2976N/Aecho %INSTANCE_ROOT%\config\java.properties.
3824N/Aecho 4. Run the command-line %INSTALL_ROOT%\bat\dsjavaproperties.bat
2976N/Apause
2976N/Aexit /B 1
2976N/A
2976N/A:setEnvironmentVars
6238N/Aif %SET_ENVIRONMENT_VARS_DONE% == "true" goto end
3007N/Aset PATH=%SystemRoot%;%PATH%
2976N/Aset SCRIPT_NAME_ARG=-Dorg.opends.server.scriptName=%SCRIPT_NAME%
2976N/Aset SET_ENVIRONMENT_VARS_DONE=true
2976N/Agoto scriptBegin
2976N/A
2976N/A:testJava
5636N/Aif "%OPENDJ_JAVA_ARGS%" == "" goto checkLegacyArgs
5636N/A:continueTestJava
5636N/A"%OPENDJ_JAVA_BIN%" %OPENDJ_JAVA_ARGS% org.opends.server.tools.InstallDS -t > NUL 2>&1
3449N/Aset RESULT_CODE=%errorlevel%
3449N/Aif %RESULT_CODE% == 13 goto notSupportedJavaHome
3449N/Aif not %RESULT_CODE% == 0 goto noValidJavaHome
6238N/Agoto end
2976N/A
5636N/A:checkLegacyArgs
5636N/Aif "%OPENDS_JAVA_ARGS%" == "" goto continueTestJava
5636N/Aset OPENDJ_JAVA_ARGS=%OPENDS_JAVA_ARGS%
5636N/Agoto continueTestJava
5636N/A
2976N/A:noValidJavaHome
5636N/Aif NOT "%OPENDJ_JAVA_ARGS%" == "" goto noValidHomeWithArgs
2976N/Aecho ERROR: The detected Java version could not be used. The detected
4261N/Aecho Java binary is:
5636N/Aecho %OPENDJ_JAVA_BIN%
5224N/Aecho You must specify the path to a valid Java 6.0 update 10 or higher version.
2976N/Aecho The procedure to follow is:
2976N/Aecho 1. Delete the file %INSTANCE_ROOT%\lib\set-java-home.bat if it exists.
5636N/Aecho 2. Set the environment variable OPENDJ_JAVA_HOME to the root of a valid
5218N/Aecho Java 6.0 installation.
4261N/Aecho If you want to have specific Java settings for each command line you must
2976N/Aecho follow the steps 3 and 4.
4261N/Aecho 3. Edit the properties file specifying the Java binary and the Java arguments
4261N/Aecho for each command line. The Java properties file is located in:
2976N/Aecho %INSTANCE_ROOT%\config\java.properties.
3824N/Aecho 4. Run the command-line %INSTALL_ROOT%\bat\dsjavaproperties.bat
2976N/Apause
2976N/Aexit /B 1
2976N/A
3449N/A:notSupportedJavaHome
5218N/Arem We get here when the java version is 6 (or up) but not supported. We run
3449N/Arem InstallDS again to see a localized message.
5636N/A"%OPENDJ_JAVA_BIN%" %OPENDJ_JAVA_ARGS% org.opends.server.tools.InstallDS -t
3449N/Apause
3449N/Aexit /B 1
3449N/A
2976N/A:noValidHomeWithArgs
4261N/Aecho ERROR: The detected Java version could not be used with the set of Java
5636N/Aecho arguments %OPENDJ_JAVA_ARGS%.
4261N/Aecho The detected Java binary is:
5636N/Aecho %OPENDJ_JAVA_BIN%
5224N/Aecho You must specify the path to a valid Java 6.0 update 10 or higher version.
2976N/Aecho The procedure to follow is:
2976N/Aecho 1. Delete the file %INSTANCE_ROOT%\lib\set-java-home.bat if it exists.
5636N/Aecho 2. Set the environment variable OPENDJ_JAVA_HOME to the root of a valid
5218N/Aecho Java 6.0 installation.
4261N/Aecho If you want to have specific Java settings for each command line you must
2976N/Aecho follow the steps 3 and 4.
4261N/Aecho 3. Edit the properties file specifying the Java binary and the Java arguments
4261N/Aecho for each command line. The Java properties file is located in:
2976N/Aecho %INSTANCE_ROOT%\config\java.properties.
3824N/Aecho 4. Run the command-line %INSTALL_ROOT%\bat\dsjavaproperties.bat
2976N/Apause
2976N/Aexit /B 1
2976N/A
2976N/A:end
2976N/Aexit /B 0