@echo off
setlocal EnableExtensions
cd /d "%~dp0"

where java >nul 2>nul
if errorlevel 1 (
  echo Floro Uploader requires Java 17 or newer, but java.exe was not found on PATH.
  echo Install Java 17+ or use the bundled-runtime Windows download.
  pause
  exit /b 1
)

set "JAVA_VERSION="
for /f "tokens=3" %%v in ('java -version 2^>^&1 ^| findstr /i "version"') do set "JAVA_VERSION=%%~v"
for /f "tokens=1,2 delims=._" %%a in ("%JAVA_VERSION%") do (
  if "%%a"=="1" (
    set "JAVA_MAJOR=%%b"
  ) else (
    set "JAVA_MAJOR=%%a"
  )
)

if not defined JAVA_MAJOR (
  echo Could not determine the installed Java version.
  echo Floro Uploader requires Java 17 or newer, or the bundled-runtime Windows download.
  pause
  exit /b 1
)

if %JAVA_MAJOR% LSS 17 (
  echo Floro Uploader requires Java 17 or newer, but PATH is using Java %JAVA_VERSION%.
  echo Older Java versions are missing java.net.http and will crash during startup.
  echo Install Java 17+ or use the bundled-runtime Windows download.
  pause
  exit /b 1
)

java -jar floro-uploader.jar %*
