@echo off
set argfullpath=%0
for %%F in ("%argfullpath%") do set workingdir=%%~dpF
echo Working Dir : %workingdir%

rem Find executable jar file
for %%a in (%workingdir%iot-setup-manager-*.jar) do (
    set JAR_FILE=%%a
)

IF NOT "%JAR_FILE%" == "" ( 
    IF EXIST %workingdir%\..\..\jdk ( 
        echo Use embedded java in Tizen Studio
        set JAVA_EXE_FILE=%workingdir%\..\..\jdk\bin\java
    ) ELSE (
        IF NOT "%JAVA_HOME%" == "" ( 
            echo Use JAVA_HOME : %JAVA_HOME%
            set JAVA_EXE_FILE=%JAVA_HOME%\bin\java
        ) ELSE (
            echo Use java program files.
            set JAVA_EXE_FILE=java
        )
    )
)

IF NOT "%JAVA_EXE_FILE%" == "" ( 
    echo %JAVA_EXE_FILE% -jar %JAR_FILE%
     "%JAVA_EXE_FILE%" -jar %JAR_FILE%
)
