# 中小学数学卷子自动生成程序 - PowerShell启动脚本 Write-Host "====================================" -ForegroundColor Green Write-Host " 中小学数学卷子自动生成程序" -ForegroundColor Yellow Write-Host "====================================" -ForegroundColor Green Write-Host "" # 设置UTF-8编码 [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # 检查Java环境 try { $javaVersion = java -version 2>&1 Write-Host "✓ Java环境检测正常" -ForegroundColor Green } catch { Write-Host "✗ 错误:未找到Java环境,请先安装Java!" -ForegroundColor Red Write-Host "下载地址:https://www.oracle.com/java/technologies/downloads/" -ForegroundColor Yellow Read-Host "按Enter键退出" exit 1 } # 切换到脚本所在目录 Set-Location -Path $PSScriptRoot # 检查是否已编译 if (-not (Test-Path "bin\App.class")) { Write-Host "正在编译Java源文件..." -ForegroundColor Cyan $compileResult = javac -d bin src\*.java 2>&1 if ($LASTEXITCODE -ne 0) { Write-Host "✗ 编译失败!" -ForegroundColor Red Write-Host $compileResult -ForegroundColor Red Read-Host "按Enter键退出" exit 1 } Write-Host "✓ 编译完成!" -ForegroundColor Green Write-Host "" } # 运行程序 Write-Host "启动数学试卷生成程序..." -ForegroundColor Cyan Write-Host "" java -cp bin src.App