How to uninstall Java SE from the command line

Oracle states that the Java SE installer is built using MSI, but the help page, rather unhelpfully doesn't list uninstall options.

I need to do a command line uninstall, and I can't figure out or find relevant the options for 1.6.21

I've tried wrapping the installer .exe in msiexec using msiexec /q /x <jre>.exe, but this just reports that the installation package could not be opened.

Running the installer .exe with the /s /x option just hangs.

Edited to add: msiexec /x {3248F0A8-6813-11D6-A77B-00B0D0160021} /q => "This action is only valid for products that are urrently installed"

Anyone got the right command line?


You can find the correct product code to pass to msiexec /x by opening in the registry (regedit). Open the key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

Select the Uninstall key and "Find" from the "Edit" menu. Search for "Java." This should show which subkey the Java is located under. One of the keys is "UninstallString." Use this command to uninstall Java. Note however, this will only work on other machines if the exact same version of Java is installed.


There are 2 places where you might find the product code:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\4EA42A62D9304AC4784BF238120662FF\InstallProperties

or

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

You should be able to find the uninstall string from the key UninstallString; something like: MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83216026FF}