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.
The WMIC methods works great Except, we need the switch that will keep it from EVER rebooting the system.
I am doing silent install of the latest Java versions and I need to 100% uninstall all other versions prior to installing the latest, and the system MUST NEVER reboot until ALL the uninstalls and install are complete. Even then it should not re-boot until I manually tell it to.
Thanks for any one who can find the last step to make this the perfect way to get rid of old Java's silently and install the newest ones.
Ralph
There is a switch NOT to reboot, here is an example of what I used:
wmic product where "name like 'Java%%' and not name like 'Java 8 Update 151%%'" call uninstall /nointeractive|wmic && shutdown /a
Can I add this command in a batch file and execute it? Does WMIC need anything to start if it the batch file or can it run as a cmd file?
wmic product where "name like 'Java%%' and not name like 'Java 8 Update 151%%'" call uninstall /nointeractive|wmic && shutdown /a
This has never restarted a machine and I've been using this for quite a while now…
wmic product where "name like 'Java(TM)%%'" call uninstall /nointeractive works well but I have a need to keep one specific older version. Is there any way to and an exception to this command to say delete all over version 7 except for 7.71?
Because Google brought me here I will tell a solution which I found so that others can also use it:
wmic product where "name like '%%java%%' and not name like 'Java 8 Update 65'" call uninstall /nointeractive
The command will cause a reboot if a browser is open when the command is run!
I guess we run commands to kill the open browsers? – Still disruptive.
Hi,
If you're looking for a deployment solution I strongly recommend "PowerShell App Deployment Toolkit" (http://psappdeploytoolkit.com/). Open source, light and highly customizable. But if you're simply looking for a one-liner the above solution is the best I've come across so far.
Is it possible to use this with SCCM 2012? It does works locally.
Hi Soul,
Yes, you could create a Program package or put it as a "Pre-install" step in your new application deployment. I always prefer to run a pre-install section which cleans out all the older versions.
Best regards,
Joakim
Very helpful, thanks very much for the post.
Hi :)
For Java 5 (and probably below), use
wmic product where "name like 'J2SE%%'" call uninstall /nointeractive
Why Java5 ? We have a very old software which can only work under Java 5 :-/
Java 5… Ouch, time for an update for sure! :)
Thanks for the info, we're using Micro Focus ZCM to deploy to both domain connected and dis-joined devices. We're going with the approach of removing all versions of Java from our desktops.