build-and-run.bat 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. @echo off
  2. echo Building and Running Chronic Disease App...
  3. REM Kill any running Java processes
  4. echo Checking for running Java processes...
  5. tasklist | findstr java >nul 2>nul
  6. if %errorlevel% equ 0 (
  7. echo Found running Java processes. Attempting to terminate...
  8. taskkill /F /IM java.exe >nul 2>nul
  9. if %errorlevel% equ 0 (
  10. echo Successfully terminated Java processes.
  11. ) else (
  12. echo Warning: Failed to terminate some Java processes. Please check manually.
  13. )
  14. ) else (
  15. echo No running Java processes found.
  16. )
  17. REM Switch to script directory to ensure Maven runs in project folder
  18. pushd "%~dp0"
  19. REM Check if Maven is installed
  20. where mvn >nul 2>nul
  21. if %errorlevel% neq 0 (
  22. echo Error: Maven is not installed or not in PATH
  23. pause
  24. exit /b 1
  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