@echo off
REM CMD Java Environment Switch - {{env_name}}
REM Generated by fnva

REM Set new JAVA_HOME
set "JAVA_HOME={{escape_backslash java_home}}"

REM Set fnva environment tracking
set "FNVA_CURRENT_JAVA={{env_name}}"
set "FNVA_ENV_TYPE=Java"

REM Update PATH to include Java bin
set "PATH={{escape_backslash java_bin}};%PATH%"

REM Verify the switch
echo ✅ Switched to Java environment: {{env_name}}
echo 📁 JAVA_HOME: %JAVA_HOME%
echo 🔍 Java Version:
if exist "{{escape_backslash java_bin}}\java.exe" (
    "{{escape_backslash java_bin}}\java.exe" -version 2>&1
) else (
    echo    Failed to get Java version
)

REM Add to history
echo fnva java use {{env_name}} >> "%USERPROFILE%\.fnva\history" 2>nul