Powershell - Script Java JRE Upgrade

Posted on 2014-08-25
Last Modified: 2014-09-17
I currently run the Java JRE on my 2000+ workstations.  Unfortunately, I don't have a good enterprise deployment method for Java.  Historically, I have relied on the version that would have been installed upon image deployment to last the OS through its lifetime in the enterprise.  Once the machine needs to be reimaged, a new version of Java will be installed as part of the imaging process.  This has worked well, until now.  I have now been informed that the version of my JRE on the majority of my machines is too old to support a business application that is widely used.  I'm now faced with the question of how to update many older versions of Java to something more recent.

I'm thinking that a Powershell script might be the way to go, as this is my language of choice.  Would it be possible to pull a value from the registry into a variable that would then allow me to uninstall an old version?  I have many different updates of Java 7 installed in my enterprise, so not all machines will have the same versioning.  I then need to script an unattended install of Java 7.65 (or newest version) to upgrade the machines.  In my experience, the Java installer does not replace old versions, it only installs two versions side-by-side.

What would be the best way to conquer this task?
Question by:marrj
    LVL 28

    Expert Comment

    I would say an easy route would be querying the registry for the version value you need.

    If the version is less than the current expected version then copy and run the msi that you would use to install the latest version.

    If you can give me an example of the output from a computer where you query for the version installed. maybe I can give more details.
    LVL 38

    Accepted Solution

    In my experience, an installation of Java will upgrade an existing installation if:
    - the major version number is the same (i.e. 1.7_65 will upgrade 1.7_17)
    - and if the previous install is in the default path.  I can't remember the terms that Oracle uses to describe this, but there are two types of install: one using the generic/default path (like "C:\Program Files (x86)\Java\jre7"), and another using a version-specific path (usually meant for installing multiple versions or when an app is dependent on a specific version being installed).

    You may test out deploying via Group Policy Software Deployment.  To do so you will have to extract the .MSI.
    You can then push out updates in the same way.  May not help you with cleaning up old versions, but would probably be a good path moving forward.  I've played around with this before, and it seems to fit your scenario.  Perhaps pushing out the latest, and then running the Java Uninstall Tool (but that would require user intervention).

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now