Commands for installing Java(TM) SE Development Kit 21 without prompts, removing it again and detecting it from deployment tools. A command is shown only when it is certain: from the manifest or the installer technology’s documented default.
Related guide: Silent install switches: MSI, NSIS, Inno Setup · Uninstall a program with the registry or PowerShell
With winget
PowerShell
winget install --id Oracle.JDK.21 -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id Oracle.JDK.21 -e --silentwinget uninstall --id Oracle.JDK.21 -e --silentBy installer
64-bit · MSI · All users
Silent install
msiexec /i jdk-21.0.12_windows-x64_bin.msi /qn /norestartWrite a log
msiexec /i jdk-21.0.12_windows-x64_bin.msi /qn /norestart /l*v "%TEMP%\java-tm-se-development-kit-21-install.log"Uninstall
msiexec /x {4D090225-3565-56C2-8ECB-9153E42067C3} /qn /norestart- MSI product code
- {4D090225-3565-56C2-8ECB-9153E42067C3}
- Uninstall registry key
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4D090225-3565-56C2-8ECB-9153E42067C3}
PowerShell: download, verify, install
Downloads the official file, checks its SHA256 and installs it silently.
install-java-tm-se-development-kit-21.ps1
$url = 'https://download.oracle.com/java/21/archive/jdk-21.0.12_windows-x64_bin.msi'
$sha256 = '0E15B56FC917F95E0F49478F966E31716054D95A80960FE7E2C36A585F2A5EFD'
$file = Join-Path $env:TEMP 'jdk-21.0.12_windows-x64_bin.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait