6 Replies Latest reply on Dec 21, 2016 9:01 AM by dgonzalez

    Java Install

    TxDMV-IT Apprentice

      I need help installing Java 8 update 102

       

      I work for a state agency that is in the process of implementing Patch Management in LANDesk version 9.60.2.48, but I need to install Java 8 update 102 on 400 computers by Thursday. there is a mix of 32 & 64 bit workstations.

       

      I created an executable package that installs "jre-8u102-windows-i586.exe" with command line switches "INSTALL_SILENT=1 AUTO_UPDATE=0 REBOOT=0 SPONSORS=0 REMOVEOUTOFDATEJRES=1 /L C:\JAVA.log".

       

      I pushed it to about a dozen or so test workstations and all report that it was a successful install. But after checking the workstations, it copied to all workstations, but did not remove the old version or install on about a third of them.

       

      Does anyone have a batch or executable Java LANDesk package that will remove old versions, install the current version with the command line switches listed above, and is able to verify that it actually installed?

       

      I am still learning LANDesk... Please dumb it down for me.

       

      Any assistance will be greatly appreciated.

       

      Thanks in advanced,

       

      Jack

        • 1. Re: Java Install
          dgonzalez Apprentice

          I have to do this with each version release. I use this powershell script to accomplish this. It searches for the most recent java version automatically by version number and then uninstalls anything older than the latest version.

           

          #This script is used to remove any old Java versions, and leave only the newest.

          #Original author: mmcpherson

          #Version 1.0 - created 2015-04-24

          #Version 1.1 - updated 2015-05-20

          #            - Now also detects and removes old Java non-update base versions (i.e. Java versions without Update #)

          #            - Now also removes Java 6 and below, plus added ability to manually change this behaviour.

          #            - Added uninstall default behaviour to never reboot (now uses msiexec.exe for uninstall)

          #Version 1.2 - updated 2015-07-28

          #            - Bug fixes: null array and op_addition errors.

          #

          #

          # IMPORTANT NOTE: If you would like Java versions 6 and below to remain, please edit the next line and replace $true with $false

          $UninstallJava6andBelow = $true

           

          #Declare version arrays

          $32bitJava = @()

          $64bitJava = @()

          $32bitVersions = @()

          $64bitVersions = @()

           

          #Perform WMI query to find installed Java Updates

          if ($UninstallJava6andBelow) {

              $32bitJava += Get-WmiObject -Class Win32_Product | Where-Object {

                  $_.Name -match "(?i)Java(\(TM\))*\s\d+(\sUpdate\s\d+)*$"

              }

              #Also find Java version 5, but handled slightly different as CPU bit is only distinguishable by the GUID

              $32bitJava += Get-WmiObject -Class Win32_Product | Where-Object {

                  ($_.Name -match "(?i)J2SE\sRuntime\sEnvironment\s\d[.]\d(\sUpdate\s\d+)*$") -and ($_.IdentifyingNumber -match "^\{32")

              }

          } else {

              $32bitJava += Get-WmiObject -Class Win32_Product | Where-Object {

                  $_.Name -match "(?i)Java((\(TM\) 7)|(\s\d+))(\sUpdate\s\d+)*$"

              }

          }

           

          #Perform WMI query to find installed Java Updates (64-bit)

          if ($UninstallJava6andBelow) {

              $64bitJava += Get-WmiObject -Class Win32_Product | Where-Object {

                  $_.Name -match "(?i)Java(\(TM\))*\s\d+(\sUpdate\s\d+)*\s[(]64-bit[)]$"

              }

              #Also find Java version 5, but handled slightly different as CPU bit is only distinguishable by the GUID

              $64bitJava += Get-WmiObject -Class Win32_Product | Where-Object {

                  ($_.Name -match "(?i)J2SE\sRuntime\sEnvironment\s\d[.]\d(\sUpdate\s\d+)*$") -and ($_.IdentifyingNumber -match "^\{64")

              }

          } else {

              $64bitJava += Get-WmiObject -Class Win32_Product | Where-Object {

                  $_.Name -match "(?i)Java((\(TM\) 7)|(\s\d+))(\sUpdate\s\d+)*\s[(]64-bit[)]$"

              }

          }

           

          #Enumerate and populate array of versions

          Foreach ($app in $32bitJava) {

              if ($app -ne $null) { $32bitVersions += $app.Version }

          }

           

          #Enumerate and populate array of versions

          Foreach ($app in $64bitJava) {

              if ($app -ne $null) { $64bitVersions += $app.Version }

          }

           

          #Create an array that is sorted correctly by the actual Version (as a System.Version object) rather than by value.

          $sorted32bitVersions = $32bitVersions | %{ New-Object System.Version ($_) } | sort

          $sorted64bitVersions = $64bitVersions | %{ New-Object System.Version ($_) } | sort

          #If a single result is returned, convert the result into a single value array so we don't run in to trouble calling .GetUpperBound later

          if($sorted32bitVersions -isnot [system.array]) { $sorted32bitVersions = @($sorted32bitVersions)}

          if($sorted64bitVersions -isnot [system.array]) { $sorted64bitVersions = @($sorted64bitVersions)}

          #Grab the value of the newest version from the array, first converting

          $newest32bitVersion = $sorted32bitVersions[$sorted32bitVersions.GetUpperBound(0)]

          $newest64bitVersion = $sorted64bitVersions[$sorted64bitVersions.GetUpperBound(0)]

           

          Foreach ($app in $32bitJava) {

              if ($app -ne $null)

              {

                  # Remove all versions of Java, where the version does not match the newest version.

                  if (($app.Version -ne $newest32bitVersion) -and ($newest32bitVersion -ne $null)) {

                     $appGUID = $app.Properties["IdentifyingNumber"].Value.ToString()

                     Start-Process -FilePath "msiexec.exe" -ArgumentList "/qn /norestart /x $($appGUID)" -Wait -Passthru

                     #write-host "Uninstalling 32-bit version: " $app

                  }

              }

          }

           

          Foreach ($app in $64bitJava) {

              if ($app -ne $null)

              {

                  # Remove all versions of Java, where the version does not match the newest version.

                  if (($app.Version -ne $newest64bitVersion) -and ($newest64bitVersion -ne $null)) {

                  $appGUID = $app.Properties["IdentifyingNumber"].Value.ToString()

                     Start-Process -FilePath "msiexec.exe" -ArgumentList "/qn /norestart /x $($appGUID)" -Wait -Passthru

                     #write-host "Uninstalling 64-bit version: " $app

                  }

              }

          }

          • 2. Re: Java Install
            TxDMV-IT Apprentice

            Should I be able to copy it to a text file, save it with a .ps1 file extension, Build a "PowerShell Package" and push it as is without modifications?

             

            Also... Do you use the same method to install Java that I previously described?

             

            As I stated previously, I am still learning LANDesk. It is kind of tough to learn without formal training and also having to deal with workstation break-fix issues.

             

            Thanks,

             

            Jack

            • 3. Re: Java Install
              dgonzalez Apprentice

              Yes copy it to notepad and give it a .ps1 extension. I use the MSI file instead of the exe file due to preference but the way you have it setup will produce the same results. You can add the java package as a dependency, this will install java first then run the powershell script after.

               

              Capture.PNG

              1 of 1 people found this helpful
              • 4. Re: Java Install
                msantos Rookie

                Very helpful - thanks for sharing.

                How does it determine what the latest version of Java is?

                Please let me know.

                • 5. Re: Java Install
                  brad.e.smith Apprentice

                  Just wanted to check to see what you ultimately did to complete this task. Getting ready to deploy Java8u111 on my environment.

                  • 6. Re: Java Install
                    dgonzalez Apprentice

                    I deployed 8u111 using the msi file, you can find it by running the installer and looking under C:\Users\USERNAME\AppData\LocalLow\Oracle\Java\jre1.8.0_111

                    Created an mst file since I needed to set certain properties for our environment

                     

                    You can add REMOVEOLDERJRES with the value of 1 under the property table to force uninstall of previous versions if you are creating an mst file or pass REMOVEOLDERJRES=1 to the msi file as a parameter. Sometimes it removes previous versions sometimes it doesn't which is why I run the powershell script after for clean up.

                     

                    You can find a list of some of the properties here Installing With a Configuration File

                    1 of 1 people found this helpful