Script for the complete, automated removal of Java from Windows 10 and Windows 11: it closes running processes, uninstalls packages, cleans up leftover folders, registry keys, the JAVA_HOME variable, and Java entries in PATH.
| File | Description |
|---|---|
uninstall-java.bat |
Main script, run this one |
uninstall-java.ps1 |
PowerShell module invoked by the batch script (must stay in the same folder) |
- ✅ Compatible with Windows 10 and Windows 11
- ✅ Automatic administrator elevation, with anti-loop protection
- ✅ Explicit confirmation required before proceeding (Y/N)
- ✅ Automatically closes active Java processes (
java.exe,javaw.exe,javaws.exe) - ✅ Uninstalls via winget (Java, OpenJDK, Eclipse Temurin, Zulu)
- ✅ Uninstalls via PowerShell (
Get-Package/Uninstall-Package) - ✅ Silently uninstalls via native registry Uninstall entries, matched by
DisplayName(covers MSI installers too, not just winget/Get-Package) - ✅ Removes leftover folders (Oracle, Adoptium, Zulu, AdoptOpenJDK)
- ✅ Cleans up
JavaSoftregistry keys - ✅ Removes the
JAVA_HOMEenvironment variable (system and user) - ✅ Cleans up Java-related entries in
PATH(system and user) - ✅ Detailed log of the operation (
uninstall-java-log.txt)
- Download both files (
uninstall-java.batanduninstall-java.ps1) into the same folder - Right-click
uninstall-java.batand choose "Run as administrator" (or just run it normally — it will request elevation on its own) - Confirm the operation when prompted (Y/N)
- Wait for the process to complete
- Restart your PC to apply the changes
⚠️ Warning: this script removes all Java versions installed on the system, including any OpenJDK/Temurin/Zulu distributions. Make sure you don't have applications depending on Java before running it.
- Windows 10 or Windows 11
wingetinstalled (included by default on Windows 11 and recent Windows 10 builds) — if missing, the script automatically skips this step without raising errors- Administrator privileges
A uninstall-java-log.txt file is generated in the same folder as the script once execution completes, useful for checking which components were actually removed or whether any errors occurred.
- Close processes – terminates any running Java processes to avoid locked files
- Winget – uninstalls the most common Java packages (if winget is available on the system)
- PowerShell (
uninstall-java.ps1) – removes packages detected viaGet-Package, finds registry Uninstall entries with aDisplayNamematching Java/JDK/JRE/OpenJDK/Temurin/Zulu and silently uninstalls them (handling both MSI and NSIS/InstallShield installers), then cleans upPATHfrom any Java references - File system cleanup – deletes leftover Oracle/OpenJDK/Temurin/Zulu folders
- Registry and environment cleanup – removes the
JavaSoftkeys and theJAVA_HOMEvariable
Pull requests and issue reports are welcome! If you find a Java path or installer not covered by the script, please open an issue.
Distributed under the MIT license.
Made by lorenzocaputodev
