-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.ps1
More file actions
60 lines (53 loc) · 1.83 KB
/
Copy pathrun.ps1
File metadata and controls
60 lines (53 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
$jar = "Jar Output\Progressive-Java-Client.jar"
if (-not (Test-Path $jar)) {
Write-Host "JAR not found - building first..."
& "$PSScriptRoot\build.ps1"
if ($LASTEXITCODE -ne 0) { throw "Build failed." }
}
function Find-JavaHome {
$javacCmd = Get-Command javac -ErrorAction SilentlyContinue
if ($javacCmd) {
$ver = (& $javacCmd.Source -version 2>&1) -replace 'javac ', ''
$major = [int]($ver -split '[\._]')[0]
if ($major -ge 17) { return (Split-Path (Split-Path $javacCmd.Source)) }
}
$roots = @(
"$env:ProgramFiles\Java",
"$env:ProgramFiles\Eclipse Adoptium",
"$env:ProgramFiles\Microsoft",
"$env:ProgramFiles\Amazon Corretto",
"${env:ProgramFiles(x86)}\Java"
)
foreach ($root in $roots) {
if (-not (Test-Path $root)) { continue }
Get-ChildItem $root -Directory | Sort-Object Name -Descending | ForEach-Object {
$javacBin = Join-Path $_.FullName "bin\javac.exe"
if (Test-Path $javacBin) {
$ver = (& $javacBin -version 2>&1) -replace 'javac ', ''
$major = [int]($ver -split '[\._]')[0]
if ($major -ge 17) { return $_.FullName }
}
}
}
return $null
}
$javaHome = Find-JavaHome
if (-not $javaHome) {
throw "No JDK 17 or newer found. Download from https://adoptium.net"
}
$javawBin = Join-Path $javaHome "bin\javaw.exe"
if (-not (Test-Path $javawBin)) {
$javawBin = Join-Path $javaHome "bin\java.exe"
}
Write-Host "Launching with $javawBin"
$jvmArgs = @(
"--enable-native-access=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"-Dsun.java2d.noddraw=true",
"-jar",
$jar
)
& $javawBin @jvmArgs