@echo off
setlocal
set "DIR=%~dp0"
if exist "%DIR%vlxjre\bin\java.exe" (
  set "JAVA=%DIR%vlxjre\bin\java.exe"
) else if defined APP_JRE_HOME (
  set "JAVA=%APP_JRE_HOME%\bin\java.exe"
) else (
  echo P4JX runtime JRE not found; rebuild the application package. 1>&2
  exit /b 1
)

set "CP=%DIR%app.p4jx"
set "JVM_OPTS="
if defined APP_JAVA_OPTS set "JVM_OPTS=%JVM_OPTS% %APP_JAVA_OPTS%"
"%JAVA%" %JVM_OPTS% -cp "%CP%" io.p4jx.enc.MainKt %*
exit /b %ERRORLEVEL%
