I received an inquiry from one of my mid-size (100-200 users) customers today. They’ve been planning an implementation of a new online service which requires the latest Java version.

The clients have a large quantity of outdated versions of Java, which needed to be uninstalled before we deployed the newest version.
They are currently running Windows 7 and Windows 8, so somewhat modern operative systems :)

I needed the following:

  • Silent uninstall of ALL Java versions.
  • Silent installation.

I started by trying out JavaRa which I’ve used previously for other customers. However it did not function the way I wanted. The latest current version (2.6) does not allow a silent uninstall.

I came across a built in solution using Windows Management Instrumentation Command-line (WMIC). It can with a single command-line remove all older versions of the program, without the need of third-party software.

If you want to remove all Java-related software use the following line:

wmic product where "name like 'Java%%'" call uninstall /nointeractive

If you would like to uninstall releases before version 7 (they previously added (TM) in the name) use:

wmic product where "name like 'Java(TM)%%'" call uninstall /nointeractive

For only version 7 and its sub-releases:

wmic product where "name like 'Java 7%%'" call uninstall /nointeractive

To uninstall all Java versions besides Java 8 Update 65

wmic product where "name like 'Java%%' and not name like 'Java 8 Update 65%%'" call uninstall /nointeractive

Please let me know if this helped you or if you need further assistance.