@echo off
REM "DM223 JRE 1.5.0_6 no more embedded"

REM Check if the LSBM_JAVA_HOME is defined
if "%LSBM_JAVA_HOME%" =="" goto :lsbm_java_home_not_defined

REM Check if the LSBM_JAVA_HOME references an existing directory
if not exist "%LSBM_JAVA_HOME%" goto :lsbm_java_home_not_java_binary

REM Check if the LSBM_JAVA_HOME contains a java executable
if not exist "%LSBM_JAVA_HOME%\bin\java.exe" goto :lsbm_java_home_not_java_binary
	
REM Check if the LSBM_JAVA_HOME references a JRE
"%LSBM_JAVA_HOME%\bin\java.exe" -version 2> nul
if %ERRORLEVEL% NEQ 0 goto :lsbm_java_home_not_java_binary

REM invoke the installer
"%LSBM_JAVA_HOME%\bin\java" -jar ..\common\install.jar
if %ERRORLEVEL% NEQ 0 PAUSE
EXIT /B %ERRORLEVEL% 

:lsbm_java_home_not_defined
title ERROR :lsbm_java_home_not_defined
echo Before starting the LSBM installation, you must install a Java JRE 
echo supported by LSBM and configure the LSBM_JAVA_HOME environment variable. 
echo The LSBM_JAVA_HOME environment variable is not defined. Refer to the LSBM 
echo installation guide to know how to do it and what are the Java JRE
echo versions.			                                                               
PAUSE
EXIT /B 1																		

:lsbm_java_home_not_java_binary
title ERROR :lsbm_java_home_not_java_binary                
echo Before starting the LSBM installation, you must install a Java JRE
echo supported  by LSBM and configure the LSBM_JAVA_HOME environment variable.
echo The LSBM_JAVA_HOME environment variable does not reference a Java JRE.
echo Refer to the LSBM installation guide to know how to do it and what are 
echo the Java JRE versions.			                                                               
PAUSE
EXIT /B 1