Crew Two

Java 8 Update 161

Packaging process for Oracle Java Runtime Environment
Version 8 Update 161

SUMMARY

This post outlines the process for packaging Oracle JRE (Java).
This process is for 32-bit Java but can be repeated for the 64-bit version.

Obtain Package Source

Download Java from java.com.
Download the 32-bit Windows Offline version.

Extract MSI installer from Package Source

The Java installer downloads as an executable, but this is just a wrapper for the MSI. To extract the MSI installer:

  1. Find and run the executable as an administrator to display the splash screen, but do not click through the prompts. Leave this window open for now.
  2. Browse to %userprofile%\AppData\LocalLow\Oracle\Java\ jre1.8.0_161\ and copy the MSI to your package folder.
  3. Click Cancel on the open installer window.

Create Scripts for Install and Uninstall

Create or update a set of text-based scripts as per below with the contents provided. These files can be adjusted to your preferences as required. Some of the settings in this example:

  • Automatic updates are disabled
  • No Start Menu is created
  • No reboot after install

The icon file is for use with the SCCM catalog.

Install

The installer is a Powershell script. It will close all browsers and any Java iteration, and uninstall the previous version of Java.

Install.ps1

# Powershell script to install Oracle Java 1.8.0_161
# Created 22/01/2018 | cru2.io

# Set Variables
$CurrentPath = Split-Path -Parent $MyInvocation.MyCommand.Definition

# Close all browsers and java versions
kill -processname chrome, firefox, safari, iexplore, Microsoft.Edge, java, javaw, javawS, jp2Launcher, jusched, jqs -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null

# unInstall old versions
$uninst = Get-WmiObject -Class win32_product | where { $_.Name -like “*Java*”}

If ($uninst -ne $null)
    {
    ForEach ($app in $uninst)
        {Start-Process -FilePath MsiExec.exe  -ArgumentList “/x $($app.IdentifyingNumber) REBOOT=R /qn” -Wait -PassThru -NoNewWindow -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null}
    }

# Install
Start-Process -FilePath MsiExec.exe -ArgumentList “/i `”$CurrentPath\jre1.8.0_161.msi`” REBOOT=R ALLUSERS=2 AUTO_UPDATE=0 EULA=0 NOSTARTMENU=1 SPONSORS=0 WEB_ANALYTICS=0 WEB_JAVA=1 WEB_JAVA_SECURITY_LEVEL=H SILENTINSTALL=1 INSTALLDIR=`”C:\Program Files\Java\jre8`” /qn” -Wait -PassThru -NoNewWindow -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null

Uninstall

The uninstaller is a Powershell script. It will close all browsers and any Java iteration.

unInstall.ps1

# Powershell script to uninstall Oracle Java 1.8.0_161
# Created 22/01/2018 | cru2.io

# Set Variables
$CurrentPath = Split-Path -Parent $MyInvocation.MyCommand.Definition

# Close all browsers and java versions
kill -processname chrome, firefox, safari, iexplore, Microsoft.Edge, java, javaw, javawS, jp2Launcher, jusched, jqs -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null

# unInstall
$uninst = Get-WmiObject -Class win32_product | where { $_.Name -like “*Java*”}

If ($uninst -ne $null)
    {
    ForEach ($app in $uninst)
        {Start-Process -FilePath MsiExec.exe  -ArgumentList “/x $($app.IdentifyingNumber) REBOOT=R /qn” -Wait -PassThru -NoNewWindow -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null}
    }

Deployment Info

This can also be found in a text file in the package directory.

deploymentInfo.txt

Oracle Java Runtime Environment 64-bit
1.8.0_161
Program Files (x86)\Java\jre8

{26A24AE4-039D-4CA4-87B4-2F32180161F0}

Uninstall registry key

About: nick