build-and-run.bat 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. @echo off
  2. echo Building and Running Chronic Disease App...
  3. REM Switch to script directory to ensure Maven runs in project folder
  4. pushd "%~dp0"
  5. REM Check if Maven is installed
  6. where mvn >nul 2>nul
  7. if %errorlevel% neq 0 (
  8. echo Error: Maven is not installed or not in PATH
  9. pause
  10. exit /b 1
  11. )
  12. REM Kill any running Java processes
  13. echo Checking for running Java processes...
  14. tasklist | findstr java >nul 2>nul
  15. if %errorlevel% equ 0 (
  16. echo Found running Java processes. Attempting to terminate...
  17. taskkill /F /IM java.exe >nul 2>nul
  18. if %errorlevel% equ 0 (
  19. echo Successfully terminated Java processes.
  20. ) else (
  21. echo Warning: Failed to terminate some Java processes. Please check manually.
  22. )
  23. ) else (
  24. echo No running Java processes found.
  25. )
  26. echo Cleaning log directory...
  27. if exist logs (
  28. rmdir /s /q logs
  29. echo Log directory cleared.
  30. ) else (
  31. echo No log directory to clear.
  32. )
  33. echo Cleaning project...
  34. call mvn clean
  35. echo Building project...
  36. echo Building project (enable compiler parameters)...
  37. call mvn package -Dmaven.compiler.parameters=true
  38. if %errorlevel% neq 0 (
  39. echo Error: Build failed
  40. pause
  41. exit /b 1
  42. )
  43. echo Running application...
  44. echo Running application with JVM add-opens for java.lang.invoke...
  45. java --add-opens=java.base/java.lang.invoke=ALL-UNNAMED -jar target/ChronicDiseaseApp-1.0-SNAPSHOT.jar
  46. REM Return to original directory
  47. popd