Java

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

Despite the page title, this page is for the Java 2 Standard Edition Runtime Environment, rather than the full-blown Java or Java Software Developer Kit / SDK. This is more commonly known as the Java Runtime Environment or JRE. The JRE provides an ability for programs written in the Java programming language to be launched from a web page and run in a web browser. Derivative JREs are available from various organisations, such as IBM, this page however is for the Oracle Java Runtime Environment, previously known as the Sun Java Runtime Environment.

For security reasons you are encouraged to upgrade to the latest 'Security Baseline', which is the last released version with security fixes, which may not be the latest released version as updates are released without security fixes. Bug Fixes of the Update Release Notes under each release: http://java.sun.com/javase/6/webnotes/ReleaseNotes.html. However, if you're running JRE 6 Update 10 or onwards and haven't disabled automatic updates then JRE should automatically be downloading and installing updates.

The stable version of the JRE offered by Oracle is that which is made available from java.com. Newer versions are made available elsewhere by Oracle for developers to test against their software. That isn't to say that once a stable version is available it will only be available from java.com, it's just that this is a useful way to judge the stable version. For example currently JRE 7 is available but the version offered from java.com is 6.0u29. If you deploy JRE 7 you may find it incompatible with the software that requires it, for example LibreOffice 3.4.2 is incompatible with the initial release of JRE 7.0.


Java Runtime Environment (JRE) 8

MSI extraction: please note that as of JRE 8u60 when extracting the .msi files from the executable, they will be extracted to:

%APPDATA%\..\LocalLow\Oracle\Java\ (e.g. C:\Users\username\AppData\LocalLow\Oracle\Java)

and no longer:

%APPDATA%\..\LocalLow\Sun\Java\ (e.g. C:\Users\username\AppData\LocalLow\Sun\Java)

Oracle, in its infinite wisdom, removed patch-in-place from Java 8u20; despite a comment in the release notes that installation to version-specific directories does not indicate a static installation, silent installs add a new version instead of upgrading the old.

Here, we present three different approaches to handle this, all with different advantages and drawbacks. You can use WMI to remove all versions of Java before performing an upgrade (a popular solution), you can use PowerShell (or another scripting language) to identify and remove all versions of Java other than the one you're deploying, or you can call msiexec.exe to explicitly remove known previous versions of Java.

For the latter method, this page contains an example which removes the last version that WPKG deployed. You can also take a more thorough (but uglier to maintain) approach by trying to remove every known version of Java 8. For an example of how this works, see [Remove Java] or the oldest (pre-patch-in-place) JRE 6 packages on this page.

People switching from one method to another should note also that two of these example packages put the Java MSIs in different locations. One package requires that you rename the 64-bit MSI so that you can keep it in the same directory as the 32-bit MSI, while the other keeps the MSIs in separate directories so that you can just copy files straight across without renaming them.

All full examples install a 32-bit JRE on 32-bit Windows and install both 32- and 64-bit JREs on 64-bit Windows. In most cases the 32-bit JRE is sufficient for web use, but some programs running on the local computer (e.g. software for scientific computing or image editing) may require a 64-bit JRE.

Removal with WMIC

These fragments can be used to alter the XML in the next example to use wmic product to remove all other versions of Java before installing the new update. This method is simple and does not have any dependencies on other software for any supported version of Windows.

The drawback to this method is that an intrinsic defect in the Win32_Product WMI class (see KB974524 and this TechNet blog post about the JRE) causes Windows to perform a repair installation of every installed package on the system when you run this query. This is extremely slow and can break software, including some versions of Java, that doesn't correctly implement it.

Use this to remove all versions of Java 7:

 <install cmd='wmic product where "name like 'Java 7%%'" call uninstall' />

and to remove all Java 8 is similar:

 <install cmd='wmic product where "name like 'Java 8%%'" call uninstall' />

Indeed you can use the last line to remove Java 8, like this:

 <remove cmd='wmic product where "name like 'Java 8%%'" call uninstall' />

It's easier to maintain even if it slower to run. Java 6 can also be removed this way, but it has that ugly TM, so the command line must include it:

 <install cmd='wmic product where "name like 'Java(tm) 6 %%'" call uninstall' />

(You may need to put a space before (tm) for some versions)

These commands use pattern matching, so there is a risk of removing other unrelated packages that have e.g. "Java 8" in their names.

Install 32- and 64-bit JRE, remove the previous version

This package explicitly removes the previous version. This is the simplest and fastest method, but if a computer misses an update (e.g. if you push two versions of Java between runs of WPKG), this will miss removing an older JRE.

  1. Get the offline installers from http://www.oracle.com/technetwork/java/javase/downloads/index.html.
  2. Edit the XML:
    1. Set %prevshortupdatever% to what %shortupdatever% is currently set to.
    2. Set %shortupdatever% to the new Java — e.g. for JRE 8u45, set it to 45.
  3. Extract the MSI files:
    1. While logged on as an administrator, run the installers. When you get to the "Welcome to Java" dialog, click "Cancel". Do not continue with the installation.
    2. Navigate to %APPDATA%\..\LocalLow\Oracle\Java\ (e.g. C:\Users\username\AppData\LocalLow\Oracle\Java).
    3. Copy the 32-bit MSI file from jre1.8.0_%shortversion%\ (e.g. jre1.8.0_45\jre1.8.0_45.msi to your installer folder (%SOFTWARE\java\).
    4. Rename the 64-bit MSI file in jre1.8.0_%shortversion%_x64\ to end with _x64.msi (e.g. rename jre1.8.0_45_x64\jre1.8.0_45.msi to jre1.8.0_45_x64\jre1.8.0_45_x64.msi) and copy it to your installer folder.

To uninstall the old Java 7 and 8 versions you can use a a removal package.

<package
    id="java8"
    name="Java Runtime Environment 8"
    revision="%version%"
    reboot="false"
    priority="20">
	
    <variable name="updatever" value="08" />
    <variable name="shortupdatever" value="31" />
    <variable name="prevshortupdatever" value="25" /> <!--Previous Version-->
    <variable name="version" value="8.0.%shortupdatever%" />

    <check type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 8" />
        <check type="uninstall" condition="exists" path="Java 8 Update %updatever%" />
        <check type="uninstall" condition="exists" path="Java 8 Update %shortupdatever%" />
	<check type="uninstall" condition="exists" path="{26A24AE4-039D-4CA4-87B4-2F32180%shortupdatever%F0}" />		
    </check>
 
    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
        <exit code='any' />
    </install>
    <install cmd='msiexec /i %SOFTWARE%\java\jre1.8.0_%shortupdatever%.msi JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 /q' >	
        <exit code='any' />
    </install>
 
    <upgrade cmd='msiexec.exe /qn /x {26A24AE4-039D-4CA4-87B4-2F32180%prevshortupdatever%F0}' /> <!--Remove previous Version-->
 
    <remove cmd='msiexec.exe /qn /x {26A24AE4-039D-4CA4-87B4-2F32180%shortupdatever%F0}' />
 
  <!-- jre 64-bit install for 64-bit hosts only -->
    <check architecture="x64" type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 8 (64-bit)" />
        <check type="uninstall" condition="exists" path="Java 8 Update %updatever% (64-bit)" />
        <check type="uninstall" condition="exists" path="Java 8 Update %shortupdatever% (64-bit)" />
	<check type="uninstall" condition="exists" path="{26A24AE4-039D-4CA4-87B4-2F64180%shortupdatever%F0}" />
    </check>
 
    <install architecture="x64" cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
        <exit code='any' />
    </install>
    <install architecture="x64" cmd='msiexec /i %SOFTWARE%\java\jre1.8.0_%shortupdatever%_x64.msi JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 /q'>
        <exit code='any' />
    </install>	

    <!-- All architectures: remove Java Quick Starter -->
     <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\jqs.exe" "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever\bin\jqs.exe" -unregister'>
        <exit code='any' />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever\bin\jqs.exe" -unregister'>
        <exit code='any' />
    </install>
 
    <!-- All architectures: remove Java Auto Update -->
    <install cmd='REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v SunJavaUpdateSched /f'>
        <exit code='any' />
    </install>

    <downgrade include="install" />
 	
    <upgrade architecture="x64" cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F64180%prevshortupdatever%F0}' /> <!--Remove previous Version-->
    <upgrade include="install" />
 
    <remove architecture="x64" cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F64180%shortupdatever%F0}' />

</package>

Install 32- and 64-bit JRE, remove all other versions using PowerShell

This method uses a PowerShell script to look at uninstall information in the registry to find and remove all versions of Java 8 other than the one we're installing. This script handles downgrades correctly.

Because it requires PowerShell, this package may not work on versions of Windows prior to Windows 7 RTM. To use this package on Vista, Server 2008 or Server 2003, you'll need to install WMF 2.0.

This script uses pattern matching, so there is a risk of removing other unrelated packages that have e.g. "Java 8" in their names. This script could malfunction unless fixed when JRE 8u100 or JRE 80 are released.

This package contains an optional hack to fix installation problems sometimes seen with Java 7: It can use 7-Zip to unpack core.zip if the installer didn't. I have not yet seen this problem with Java 8, so it's possible that this is an unnecessary precaution. If you want to use this, uncomment the first half of Step 4 and ensure that 7-Zip is available at your site.

This package contains a workaround the a problem where javaws.exe and jp2launcher.exe are launched multiple times during a silent installation and never exit, blocking the Java install and breaking all other installs done (by WPKG or other programs) until the computer is restarted or someone kills them by hand. The workaround works with a PowerShell one-liner which forks and runs in the background killing these processes whenever they appear. A second one-liner kills the killer process during cleanup.

Instructions & package

  1. Get the offline installers from http://www.oracle.com/technetwork/java/javase/downloads/index.html.
  2. While logged on as an administrator, run the installers. When you get to the "Welcome to Java" dialog, click Cancel. Do not continue with the installation.
  3. Navigate to %APPDATA%\..\LocalLow\Oracle\Java.
  4. You'll see temporary folders left by the Java installer. For JRE 8u65, they will be named jre1.8.0_65 and jre1.8.0_65_x64. Move them to %SOFTWARE%\Java\.
  5. Update %shortupdatever% in this package.
<?xml version="1.0" encoding="UTF-8"?>
<packages:packages
        xmlns:packages="http://www.wpkg.org/packages" xmlns:wpkg="http://www.wpkg.org/wpkg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.wpkg.org/packages ../xsd/packages.xsd" >
<package
    id="jre8"
    name="Java Runtime Environment 8"
    revision="%version%"
    reboot="false"
    priority="20">

    <!-- UPDATE INSTRUCTIONS:

     1: Download the latest 32- and 64-bit offline installers.
     2: While logged on as an administrator, run the installers. When you get
        to the "Welcome to Java" dialog, click Cancel.
     3: Navigate to %APPDATA%\..\LocalLow\Oracle\Java
     4: Grab the folders (e.g. jre1.8.0_45 and jre1.8.0_45_x64) that the Java
        installer left there and move them to %SOFTWARE%\java\
     5: Update %shortupdatever% in this package.
    -->

    <!-- <variable name="updatever" value="08" /> -->
    <variable name="shortupdatever" value="65" />
    <variable name="version" value="8.0.%shortupdatever%" />

    <!-- Require WMF 2 if on an operating system that didn't come with PowerShell -->
    <depends package-id="wmf2" os=".+6\.0\.\d{4}" /> <!-- Vista / Server 2008 -->
    <depends package-id="wmf2" os=".+5\.[1-2]\.\d{4}" /> <!-- XP / Server 2003 -->

    <check type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 8" />
        <!-- <check type="uninstall" condition="exists" path="Java 8 Update %updatever%" /> -->
        <check type="uninstall" condition="exists" path="Java 8 Update %shortupdatever%" />
        <check type="uninstall" condition="exists" path="{26A24AE4-039D-4CA4-87B4-2F832180%shortupdatever%F0}" />        
    </check>
    <check architecture="x64" type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 8 (64-bit)" />
        <!-- <check type="uninstall" condition="exists" path="Java 8 Update %updatever% (64-bit)" /> -->
        <check type="uninstall" condition="exists" path="Java 8 Update %shortupdatever% (64-bit)" />
        <check type="uninstall" condition="exists" path="{26A24AE4-039D-4CA4-87B4-2F864180%shortupdatever%F0}" />
    </check>

    <!-- STEP 1: Kill process that may interfere with upgrade -->
    <!-- DO NOT BLINDLY REMOVE &quot; AND CONVERT TO SINGLE QUOTES! YOU WILL BREAK THIS! -->
    <install cmd='taskkill /f /im jqs.exe'>
      <exit code='any' />
    </install>
    <install cmd="powershell -executionpolicy bypass -noprofile -command &quot;start-process -nonewwindow powershell.exe -argumentlist '-executionpolicy bypass -noprofile -command &quot;&quot;do {get-process javaws,jp2launcher -erroraction silentlycontinue | stop-process; sleep -milliseconds 250} while (get-process cscript -erroraction silentlycontinue) #javakiller&quot;&quot;'&quot;" >
      <exit code='any' />
    </install>


    <!-- STEP 2: Remove previous versions of Java 8 -->
    <!-- Note that we can't just use UninstallString because Oracle decided
         to use /i in it for 8u31. -->
    <!-- Base64-encoded thing avoids quote nightmares and was made with
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes({
foreach ($i in get-itemproperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
   where-object {$_.displayname -like "Java 8*" } |
   where-object {$_.displayname -notlike "Java 8 Update $env:shortupdatever*"} ) {
  msiexec /x $i.PSChildName.ToString() /qn | write-output
}}))
    -->
    <install cmd="powershell -noprofile -EncodedCommand DQAKAGYAbwByAGUAYQBjAGgAIAAoACQAaQAgAGkAbgAgAGcAZQB0AC0AaQB0AGUAbQBwAHIAbwBwAGUAcgB0AHkAIABIAEsATABNADoAXABTAG8AZgB0AHcAYQByAGUAXABNAGkAYwByAG8AcwBvAGYAdABcAFcAaQBuAGQAbwB3AHMAXABDAHUAcgByAGUAbgB0AFYAZQByAHMAaQBvAG4AXABVAG4AaQBuAHMAdABhAGwAbABcACoAIAB8AA0ACgAgACAAIAB3AGgAZQByAGUALQBvAGIAagBlAGMAdAAgAHsAJABfAC4AZABpAHMAcABsAGEAeQBuAGEAbQBlACAALQBsAGkAawBlACAAIgBKAGEAdgBhACAAOAAqACIAIAB9ACAAfAANAAoAIAAgACAAdwBoAGUAcgBlAC0AbwBiAGoAZQBjAHQAIAB7ACQAXwAuAGQAaQBzAHAAbABhAHkAbgBhAG0AZQAgAC0AbgBvAHQAbABpAGsAZQAgACIASgBhAHYAYQAgADgAIABVAHAAZABhAHQAZQAgACQAZQBuAHYAOgBzAGgAbwByAHQAdQBwAGQAYQB0AGUAdgBlAHIAKgAiAH0AIAApACAAewANAAoAIAAgAG0AcwBpAGUAeABlAGMAIAAvAHgAIAAkAGkALgBQAFMAQwBoAGkAbABkAE4AYQBtAGUALgBUAG8AUwB0AHIAaQBuAGcAKAApACAALwBxAG4AIAB8ACAAdwByAGkAdABlAC0AbwB1AHQAcAB1AHQADQAKAH0A" >
      <exit code="any" />
    </install>
    <!-- Base64-encoded thing avoids quote nightmares and was made with:
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes({
foreach ($i in get-itemproperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
   where-object {$_.displayname -like "Java 8*" } |
   where-object {$_.displayname -notlike "Java 8 Update $env:shortupdatever*"} ) {
  msiexec /x $i.PSChildName.ToString() /qn | write-output
}}))
    -->
    <install cmd="powershell -noprofile -EncodedCommand DQAKAGYAbwByAGUAYQBjAGgAIAAoACQAaQAgAGkAbgAgAGcAZQB0AC0AaQB0AGUAbQBwAHIAbwBwAGUAcgB0AHkAIABIAEsATABNADoAXABTAG8AZgB0AHcAYQByAGUAXABXAG8AdwA2ADQAMwAyAE4AbwBkAGUAXABNAGkAYwByAG8AcwBvAGYAdABcAFcAaQBuAGQAbwB3AHMAXABDAHUAcgByAGUAbgB0AFYAZQByAHMAaQBvAG4AXABVAG4AaQBuAHMAdABhAGwAbABcACoAIAB8AA0ACgAgACAAIAB3AGgAZQByAGUALQBvAGIAagBlAGMAdAAgAHsAJABfAC4AZABpAHMAcABsAGEAeQBuAGEAbQBlACAALQBsAGkAawBlACAAIgBKAGEAdgBhACAAOAAqACIAIAB9ACAAfAANAAoAIAAgACAAdwBoAGUAcgBlAC0AbwBiAGoAZQBjAHQAIAB7ACQAXwAuAGQAaQBzAHAAbABhAHkAbgBhAG0AZQAgAC0AbgBvAHQAbABpAGsAZQAgACIASgBhAHYAYQAgADgAIABVAHAAZABhAHQAZQAgACQAZQBuAHYAOgBzAGgAbwByAHQAdQBwAGQAYQB0AGUAdgBlAHIAKgAiAH0AIAApACAAewANAAoAIAAgAG0AcwBpAGUAeABlAGMAIAAvAHgAIAAkAGkALgBQAFMAQwBoAGkAbABkAE4AYQBtAGUALgBUAG8AUwB0AHIAaQBuAGcAKAApACAALwBxAG4AIAB8ACAAdwByAGkAdABlAC0AbwB1AHQAcAB1AHQADQAKAH0A" architecture="x64" >
      <exit code="any" />
    </install>
 
    <!-- STEP 3: install -->
    <!-- STEP 3.1 install 32-bit -->
    <install cmd='msiexec /i %SOFTWARE%\java\jre1.8.0_%shortupdatever%\jre1.8.0_%shortupdatever%.msi JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 /q' />
    <!-- STEP 3.2 install 64-bit -->
    <install architecture="x64" cmd='msiexec /i %SOFTWARE%\java\jre1.8.0_%shortupdatever%_x64\jre1.8.0_%shortupdatever%.msi JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 /q' />

    <!-- STEP 4: Fix broken installations
         On the assumption that the Java 6 & Java 7 bug that leaves a broken
         installation is not fixed, I'm including this workaround.

         With Java 7's upgrade-in-place capability, I did this before the
         upgrade, but since Oracle in their infinite wisdom decided to remove
         that with Java 8, we do it now in case something went wrong.
    -->
    <!-- avoid interactive services detection if the old installation is broken -->
    <!--
    <depends package-id="7zip" />
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\core.zip" if not exist "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll" "%PROGRAMFILES%\7-Zip\7z.exe" x -y -o"%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%" "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\core.zip"'>
      <exit code="any" />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\core.zip" if not exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll" "%PROGRAMFILES%\7-Zip\7z.exe" x -y -o"%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%" "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\core.zip"'>
      <exit code="any" />
    </install>
    -->

    <!-- STEP 4.1
         The Java installer has been reorganized and this probably no longer applies. It's left
         here as a template, but feel free to remove it if you think you should.
    -->
    <!-- ... and because that won't avoid Interactive Service Detection if
         there's no core.zip: -->
    <!--
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%" if exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\msvcr100.dll" if not exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll" copy /y "%SOFTWARE%\java\jre8-installer-64.dll" "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll"'>
      <exit code="any" />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%" if exist "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\bin\msvcr100.dll" if not exist "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll" copy /y "%SOFTWARE%\java\jre8-installer-32.dll" "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll"'>
      <exit code="any" />
    </install>
    <install cmd='%COMSPEC% /C if not exist "%PROGRAMFILES(x86)%" if exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\msvcr100.dll" if not exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll" copy /y "%SOFTWARE%\java\jre8-installer-32.dll" "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\installer.dll"'>
      <exit code="any" />
    </install>
    -->



    <!-- STEP 5: cleanup -->
    <!-- All architectures: remove Java Quick Starter -->
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever%\bin\jqs.exe" "%PROGRAMFILES%\Java\jre1.8.0_%shortupdatever\bin\jqs.exe" -unregister'>
      <exit code='any' />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever%\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre1.8.0_%shortupdatever\bin\jqs.exe" -unregister'>
      <exit code='any' />
    </install>
    <!-- All architectures: disable Java Auto Update -->
    <install cmd='REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v SunJavaUpdateSched /f'>
      <exit code='any' />
    </install>

    <!-- stop our javaws killer without affecting other powershell processes -->
    <!-- have to use WMI methods because get-process doesn't see command lines -->
    <install cmd="powershell -executionpolicy bypass -noprofile -command &quot;get-wmiobject win32_process -filter &quot;&quot;&quot;&quot;name like 'powershell.exe' and commandline like '% #javakiller%'&quot;&quot;&quot;&quot; | % {invoke-wmimethod -name terminate -inputobject $_|out-null}&quot;" >
      <exit code="any" />
    </install>

 
    <remove cmd='msiexec.exe /qn /x {26A24AE4-039D-4CA4-87B4-2F832180%shortupdatever%F0}' />
    <remove architecture="x64" cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F864180%shortupdatever%F0}' />

    <downgrade include="install" />
 
    <upgrade include="install" />
 
</package>
</packages:packages>

Details of the PowerShell script

The PowerShell code is passed base64-encoded to avoid a quoting nightmare in the XML file. You can verify that it's correct (and re-encode it if you need to change it) with the following:

# 32-bit on 32-bit Windows, 64-bit on 64-bit Windows
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes({
foreach ($i in get-itemproperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
   where-object {$_.displayname -like "Java 8*" } |
   where-object {$_.displayname -notlike "Java 8 Update $env:shortupdatever*"} ) {
  msiexec /x $i.PSChildName.ToString() /qn | write-output
}}))

# 32-bit on 64-bit Windows
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes({
foreach ($i in get-itemproperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
   where-object {$_.displayname -like "Java 8*" } |
   where-object {$_.displayname -notlike "Java 8 Update $env:shortupdatever*"} ) {
  msiexec /x $i.PSChildName.ToString() /qn | write-output
}}))

Note that this consults the registry to discover what's installed instead of asking WMI; see this article to understand why.

The script uses the registry key to get the ClassID of installed JRE 8 instances instead of appending /qn to the uninstall string. The reason we do this is that for JRE 8u31, Oracle included /i in the UninstallString.

Output from msiexec is piped to write-output so that PowerShell will wait for msiexec to complete.

Java Runtime Environment (JRE) 7

JRE 7 Installer Versions

There are various versions of the installer:

  • Those from http://www.java.com/en/download/manual.jsp which are aimed at consumers. The versions available here are 'Windows 7/XP/Vista/2000/2003/2008 Online' (same as the 'Windows Online Installation' above) (jre-7-windows-i586-iftw-rv.exe) and 'Windows 7/XP/Vista/2000/2003/2008 Offline' (not the same as the 'Windows Offline Installation' above) (jre-7-windows-i586-s.exe). In releases prior to version 6 update 19 or maybe 18 the installer filename ending in -s.exe tried to download the Google Toolbar so this may still be the case with this version.

JRE 7 Installer Command-line Switches

From http://www.java.com/en/download/help/silent_install.xml and installer-options

/s, if used, indicates silent installation INSTALLDIR, if used, specifies the drive and path of the JRE.

If INSTALLDIR is not specified, the installation will go into C:\Program Files\java\jre (default location).

STATIC=1, if used, specifies a static installation. This option is available in the 6u10 release and above. For more information see Static Installation.

WEB_JAVA=0, if used, disables any Java application from running in the browser.

WEB_JAVA=1, the default, enables Java applications in the browser. This field is available as of the 7u10 release. For more information see Setting Security Levels of the Java Client..

WEB_JAVA_SECURITY_LEVEL: if used, sets the security level of unsigned Java apps running in a browser. The possible values for this field are VH (very high), H (high), M (medium, the default) or L (low). This field is available as of the 7u10 release.

The product code for Java 7u65 and later has been changed from {26A24AE4-039D-4CA4-87B4-2F832170%version%FF} (32-bit) and {26A24AE4-039D-4CA4-87B4-2F864170%version%FF} (64-bit) to {26A24AE4-039D-4CA4-87B4-2F032170%version%FF} and {26A24AE4-039D-4CA4-87B4-2F064170%version%FF}. This is especially important if you use the .msi for the installation/upgrade to Java 8.

JRE 7 Uninstall Options

The options most people use will involve pulling out the MSI file from the exe, leveraging the msiexec command flags to remove... This is fine, but who wants to do all that work at the beginning, then have to repeat it every time you want to update Java? There's also a way to do it using msiexec and uninstall strings from the registry. This is fine, too, but it is a script, and it assumes the file name doesn't change as the iterations go along... If we use WMI, however, we can just use the name of what we want to remove... This works like a champ on most windows machines (Vista and beyond, I would assume, are safe bets) and does the job quickly and properly...

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

<install cmd="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:

<install cmd="wmic product where 'name like 'Java(TM)%%'' call uninstall /nointeractive"/>

For only version 7 and its sub-releases:

<install cmd="wmic product where 'name like 'Java 7%%'' call uninstall /nointeractive"/>

JRE 7 on 32-bit Hosts

The following installs the JRE and then removes the "Java Quick Starter" service; if you want to keep "Java Quick Starter" service then just remove the line with "jqs.exe -unregister", but remember to stop/kill JQS before uninstallation. You will need to rename the installer file you downloaded to reflect that this is update 00 since Sun are being inconsistent in naming their executable files.

<package
  id="java7"
  name="Java Runtime Environment 7"
  revision="%version%"
  reboot="false"
  priority="100">

  <variable name="version" value="55" />

  <check
    type="uninstall"
    condition="exists"
    path="Java(\(TM\))* 7 Update %version%" />

  <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
    <exit code='0' />
    <exit code='1' />
    <exit code='128' />
  </install>

  <install cmd='%SOFTWARE%\jre\jre-7u%version%-windows-i586.exe /s REBOOT=Suppress' >
    <exit code='0' />
    <exit code='3010' />
  </install>

  <!-- remove Java Quick Starter -->
  <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
    <exit code='1' />
  </install>

  <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" -unregister'>
    <exit code='1' />
  </install>

  <!-- Remove Java Auto Updater -->
  <install cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

  <upgrade include='install' />

  <remove cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe' />
  <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F832170%version%FF}' >
    <exit code="0" />
    <exit code="1605" />
  </remove>
  <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F032170%version%FF}' >
    <exit code="0" />
    <exit code="1605" />
  </remove>

</package>

Install JRE 7 with msi without removing old version in a mixed 32-bit/64-bit environment

On 64-bit hosts installing the exe doesn't work: the silent install on a 64-bit host is still looking for the msi in the *System32* directory, so the best thing to do is to install the msi package.

  • jre-7-windows-i586.exe is the 32bit installer containing a msi, a cab and some other files.
  • jre-7-windows-x64.exe is a 64bit version of the above.

Run the installer without going any further, then find the extracted directory:

  • On Windows XP and possibly others, it extracts to C:\Documents and Settings\<user>\Local Settings\ApplicationData\Sun\Java\jre<version_number>
  • On Windows 7, it extracts to C:\Users\<user>\AppData\LocalLow\Sun\Java\jre<version_number>[x64]
  • On a 32-bit host it extracts to c:\Windows\system32\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.7\.
  • On a 64-bit host it extracts to c:\Windows\SysWOW64\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.7\.

Copy the content of the unpacked directory onto your server and install from it.

You should install both 32-bit and 64-bit java on 64-bit machines if you want a 32-bit browser being able to use java.

In this example, no uninstall of the old java versions as it is quite time consuming.

<?xml version="1.0" encoding="UTF-8"?>

<packages>
<!-- jre install with the msi ; for 32-bit and 64-bit hosts -->
<package
    id="jre"
    name="Java(TM) 7"
    revision="%version%"
    reboot="false"
    priority="178"
    >
    <variable name="updatever" value="07" />
    <variable name="shortupdatever" value="7" />
    <variable name="version" value="7.0.70.10" />
    <variable name="autoupdate" value="0" />
    
    <check architecture="x86" type="file" condition="exists" path="%PROGRAMFILES%\Java\jre7\bin\java.exe" />
    <check architecture="x64" type="file" condition="exists" path="%PROGRAMFILES(X86)%\Java\jre7\bin\java.exe" />
    <check type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 7" />
        <check type="uninstall" condition="exists" path="Java 7 Update %updatever%" />
        <check type="uninstall" condition="exists" path="Java 7 Update %shortupdatever%" />
    </check>

    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
      <exit code='1' />
      <exit code='128' />
    </install>
    <install
        cmd='msiexec /qn /i %SOFTWARE%\jre\jre1.7.0_u%updatever%.msi REBOOT=Suppress JAVAUPDATE=%autoupdate% CUSTOM=1'
        />
    <!-- remove Java Quick Starter -->
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='1' />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='1' />
    </install>
    <!-- Remove Java Auto Updater software -->
    <install cmd='REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v SunJavaUpdateSched /f'>
      <exit code='any' />
    </install>

    <upgrade include="install" />

    <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F832170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>
    <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F032170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>

</package>

<!-- jre 64-bit install with the msi ; for 64-bit hosts only -->
<!-- There is no Automatic Update on Jre 64bit http://www.java.com/en/download/faq/java_win64bit.xml (see "Note" at bottom of page) -->
<package
    id="jre-64"
    name="Java(TM) 7 (64-bit)"
    revision="%version%"
    reboot="false"
    priority="178"
    >
    <variable name="updatever" value="07" />
    <variable name="shortupdatever" value="7" />
    <variable name="version" value="7.0.70.11" />
    <variable name="autoupdate" value="0" />
    
    <check architecture="x64" type="file" condition="exists" path="%PROGRAMFILES%\Java\jre7\bin\java.exe" />
    <check architecture="x64" type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 7 (64-bit)" />
        <check type="uninstall" condition="exists" path="Java 7 Update %updatever% (64-bit)" />
        <check type="uninstall" condition="exists" path="Java 7 Update %shortupdatever% (64-bit)" />
    </check>

    <install architecture="x64" cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
        <exit code='1' />
        <exit code='128' />
    </install>
    <install architecture="x64" 
        cmd='msiexec /qn /i %SOFTWARE%\jre-64\jre1.7.0_u%updatever%.msi REBOOT=Suppress JAVAUPDATE=%autoupdate% CUSTOM=1'
        />    
    <!-- remove Java Quick Starter -->
    <install architecture="x64" cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='1' />
    </install>

    <upgrade include="install" />

    <remove architecture="x64" cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F864170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>
    <remove architecture="x64" cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F064170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>

</package>

</packages>

Install JRE 7 with exe and msi in a mixed 32-bit/64-bit environment in one package

The intent is to have one package which installs Java for all Windows machines.

It installs :

  • i586 version of Java on 32-bit OS
  • i586 and x64 version of Java on 64-bit OS.
  • .exe on XP and lower
  • .msi on Vista and higher

This is because I've encountered some problems using the MSI with XP.

There is also a "REG" command which removes the Java AutoUpdate, a call to "C:\Program Files\Fichiers communs\Java\Java Update\jusched.exe"

There is a long-standing bug in the installer which can leave Java inoperable, unupgradable and un-uninstallable. Under some circumstances, the upgrade process can make WPKG stall with an Interactive Services Detection dialog. To work around this problem, this package definition contains a hack that you can use as follows:

  • Provide a 7-Zip package
  • On a working 64-bit Java installation, copy %PROGRAMFILES%\Java\jre7\bin\installer.dll to %SOFTWARE%\java\installer-64.dll
  • On a working Java installation, copy %PROGRAMFILES(x86)%\Java\jre7\bin\installer.dll to %SOFTWARE%\java\installer-32.dll

If you don't want to use this workaround, simply delete everything between BEGINNING OF CLEANUP CODE and END OF CLEANUP.

<?xml version="1.0" encoding="UTF-8"?>
 
<packages>
<!-- jre install with the msi ; for 32-bit and 64-bit hosts -->
<package
    id="Java"
    name="Java(TM) 7"
    revision="%version%"
    reboot="false"
    priority="178"
    >
    <variable name="updatever" value="07" />
    <variable name="shortupdatever" value="7" />
    <variable name="version" value="7.0.%updatever%" />
    <variable name="autoupdate" value="0" />
    
    <check architecture="x86" type="file" condition="exists" path="%PROGRAMFILES%\Java\jre7\bin\java.exe" />
    <check architecture="x64" type="file" condition="exists" path="%PROGRAMFILES(X86)%\Java\jre7\bin\java.exe" />
    <check type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 7" />
        <check type="uninstall" condition="exists" path="Java 7 Update %updatever%" />
        <check type="uninstall" condition="exists" path="Java 7 Update %shortupdatever%" />
    </check>

    <!-- BEGINNING OF CLEANUP CODE
         Delete from here to the END OF CLEANUP note to disable this fix -->
    <depends package-id="7zip" />
    <!-- avoid interactive services detection if the old installation is broken -->
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\core.zip" if not exist "%PROGRAMFILES(x86)%\Java\jre7\bin\installer.dll" "%PROGRAMFILES%\7-Zip\7z.exe" x -y -o"%PROGRAMFILES(x86)%\Java\jre7" "%PROGRAMFILES(x86)%\Java\jre7\core.zip"'>
      <exit code="any" />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\core.zip" if not exist "%PROGRAMFILES%\Java\jre7\bin\installer.dll" "%PROGRAMFILES%\7-Zip\7z.exe" x -y -o"%PROGRAMFILES%\Java\jre7" "%PROGRAMFILES%\Java\jre7\core.zip"'>
      <exit code="any" />
    </install>

    <!-- ... and because that won't avoid Interactive Service Detection if
         there's no core.zip: -->
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%" if exist "%PROGRAMFILES%\Java\jre7\bin\msvcr100.dll" if not exist "%PROGRAMFILES%\Java\jre7\bin\installer.dll" copy /y "%SOFTWARE%\java\installer-64.dll" "%PROGRAMFILES%\Java\jre7\bin\installer.dll"'>
      <exit code="any" />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%" if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\msvcr100.dll" if not exist "%PROGRAMFILES(x86)%\Java\jre7\bin\installer.dll" copy /y "%SOFTWARE%\java\installer-32.dll" "%PROGRAMFILES(x86)%\Java\jre7\bin\installer.dll"'>
      <exit code="any" />
    </install>
    <install cmd='%COMSPEC% /C if not exist "%PROGRAMFILES(x86)%" if exist "%PROGRAMFILES%\Java\jre7\bin\msvcr100.dll" if not exist "%PROGRAMFILES%\Java\jre7\bin\installer.dll" copy /y "%SOFTWARE%\java\installer-32.dll" "%PROGRAMFILES%\Java\jre7\bin\installer.dll"'>
      <exit code="any" />
    </install>
    <!-- END OF CLEANUP -->


    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
      <exit code='any' />
    </install>
    <!-- .exe install (XP, 2003) -->
    <install os=".+5\.[1-2]\.\d{4}"
    cmd='%SOFTWARE%\java\jre-7u%shortupdatever%-windows-i586.exe /s REBOOT=Suppress JAVAUPDATE=%autoupdate% CUSTOM=1' />
    <!-- .msi (Seven) install http://wpkg.org/Java#Install_JRE_with_msi_without_removing_old_version_in_a_mixed_32-bit.2F64-bit_environment -->
    <install os=".+6\.[0-1]\.\d{4}"
    cmd='msiexec /qn /i %SOFTWARE%\java\jre1.7.0_%updatever%\jre1.7.0_%updatever%.msi REBOOT=Suppress JAVAUPDATE=%autoupdate% CUSTOM=1' />
    <!-- remove Java Quick Starter -->
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='any' />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='any' />
    </install>
    <!-- remove Java Auto Update -->
    <install cmd='REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v SunJavaUpdateSched /f'>
      <exit code='any' />
    </install>

    <downgrade include="install" />

    <upgrade include="install" />
 
    <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F832170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>
    <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F032170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>
 
<!-- jre 64-bit install with the msi ; for 64-bit hosts only -->
    <check architecture="x64" type="file" condition="exists" path="%PROGRAMFILES%\Java\jre7\bin\java.exe" />
    <check architecture="x64" type="logical" condition="or">
        <check type="uninstall" condition="exists" path="Java 7 (64-bit)" />
        <check type="uninstall" condition="exists" path="Java 7 Update %updatever% (64-bit)" />
        <check type="uninstall" condition="exists" path="Java 7 Update %shortupdatever% (64-bit)" />
    </check>
 
    <install architecture="x64" cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
        <exit code='any' />
    </install>
    <install architecture="x64"
    cmd='msiexec /qn /i %SOFTWARE%\java\jre1.7.0_%updatever%_x64\jre1.7.0_%updatever%.msi REBOOT=Suppress JAVAUPDATE=%autoupdate% CUSTOM=1'
    />
    <!-- remove Java Quick Starter -->
     <install architecture="x64" cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='any' />
    </install>
    <install architecture="x64" cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='any' />
    </install>
    
    <downgrade include="install" />

    <upgrade include="install" />
 
    <remove architecture="x64" cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F864170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>
    <remove architecture="x64" cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F064170%updatever%FF}' >
      <exit code="0" />
      <exit code="1605" />
    </remove>
 
</package>
 
</packages>

Disable Automatic Update (JRE 7)

The Java Auto Updater is a separate package that is automatically installed with the JRE. You can disable automatic updates by uninstalling the Java Auto Updater after the JRE is installed or upgraded, by adding the following to your package definition:

<install cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />
<upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

The Java Auto Updater Product Code in version 7 is unchanged from version 6 (current as of 7u10)

Browser Plugins (JRE7)

Disable and Remove Browser Plugins

%PROGRAMFILES% or %PROGRAMFILES(X86)%\Java\jre7\bin\ssvagent.exe -disablewebjava

Re-enable Browser Plugins

%PROGRAMFILES% or %PROGRAMFILES(X86)%\Java\jre7\bin\ssvagent.exe -forceinstall -register -new -high

Plugin Settings files

File in user path takes precedence.

%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\deployment.properties
%WINDIR%\Sun\Java\Deployment\deployment.properties

Security level parameter

deployment.security.level=MEDIUM|HIGH|VERY_HIGH

Deployment Rule Set

Is an option to define Exception Site List as in Java Control Panel within %WINDIR%\Sun\Java\Deployment\DeploymentRuleSet.jar

You may define execution exception by URL or Certificate signature. You may also specify JRE version which application should use and notify user about your policy.

For creating DeploymentRuleSet.jar, you need jar, jarsigner and keytool from Java JDK. You also need to have certificate signed by CA contained within java JRE's keystore (cacerts) or import your selfsigned certificate to your clients.

Creating DeploymentRuleSet.jar

1. Create %tmp%\ruleset.xml and specify your policy

<ruleset version="1.0+">
  <rule>
    <id title="Solitaire" location="https://host.example.com/games" />
    <action permission="SECURE-1.7" />
  </rule>
  <rule>
    <id location="https://host.example.com" />
    <action permission="run" version="" />
  </rule>
  <rule> <!-- allow anything signed with company's public cert --> 
    <id>
      <certificate hash="794F53C746E2AA77D84B843BE942CAB4309F258FD946D62A6C4CCEAB8E1DB2C6" />
    </id>
    <action permission="run" version="SECURE" />
  </rule>
  <rule> <!-- block everything else with message -->
    <id />
    <action permission="block" />
    <message>Sorry, but we only allow Solitaire and apps with our sign.</message>
    </action>
  </rule>
</ruleset>

2. Create DeploymentRuleSet.jar and sign with your certificate

"%JDK_PATH%\bin\jar" cf %tmp%\DeploymentRuleSet.jar -C %tmp% ruleset.xml
"%JDK_PATH%\Java\jdk1.7.0_51\bin\jarsigner" -keystore yourkeystore.jks %tmp%\DeploymentRuleSet.jar yourcertalias

3. (Selfsigned certs only) Import your selfsigned certificate to JRE keystore

"%JDK_PATH%\Java\jdk1.7.0_51\bin\keytool.exe" -import -alias yourcertalias -file yourcertificate.crt -keystore "%JRE_PATH%\lib\security\cacerts" -storepass changeit

4. Copy DeploymentRuleSet.jar to %SYSDIR%\Sun\Java\Deployment\DeploymentRuleSet.jar

More info from Oracle

Details about ruleset.xml (Oracle Doc)

rulset.xml DTD (Oracle Doc)

Creating Jar Tutorial (Oracle Doc)

Signing Jar Tutorial (Oracle Doc)

Java Runtime Environment (JRE) 6

JRE 6 Installer Versions

There are various versions of the installer:

  • Those from http://www.java.com/en/download/manual.jsp which are aimed at consumers. The versions available here are 'Windows 7/XP/Vista/2000/2003/2008 Online' (same as the 'Windows Online Installation' above) (jre-6u23-windows-i586-iftw-rv.exe) and 'Windows 7/XP/Vista/2000/2003/2008 Offline' (not the same as the 'Windows Offline Installation' above) (jre-6u23-windows-i586-s.exe). In versions prior to update 19 or maybe 18 the installer filename ending in -s.exe tried to download the Google Toolbar so this may still be the case with this version.

JRE 6 Java Quick Starter

"Java Quick Starter" is described as a prefetching service that should make java applications start faster. But it has a drawback: it must be killed before uninstallation or installation fails, and uninstallation via msiexec does not seem to be smart enough to do this.

This is not a problem though, simply insert the following snippet into the very first of your install AND upgrade commands of the xml from the next paragraph.

<install cmd='net STOP JavaQuickStarterService' >
  <exit code='2' />
</install>

This will stop the java quick-start service prior to installation or upgrade. In case it was already stopped (Errorlevel 2) the error is simply ignored. If you want to use it, be sure to remove the commands (%PROGRAMFILES%\Java\jre6\bin\jqs.exe -unregister') that disable the 'Java Quick Starter' from your package definition.

Although there seems to be no command line switches to allow/disallow the installation of "Java Quick Starter", the jqs.exe binary itself can be used immediately after installation in order to add/remove the "Java Quick Starter" service.

The following table shows the command line switches you can invoke with the jqs.exe binary:

C:\Program Files\Java\jre6\bin>jqs -help
Usage: jqs <mode> [<options>]

The following modes are supported:
  -help         print this help message and exit
  -register     install JQS service and register browser startup detectors
  -unregister   uninstall JQS service and unregister startup detectors
  -enable       enable JQS service
  -disable      disable JQS service
  -pause        pause prefetching
  -resume       resume prefetching
  -version      print version of the associated Java Runtime

Options include:
  -config <config>      set JQS configuration file
  -profile <profile>    set JQS profile file
  -logfile <logfile>    set JQS log file
  -verbose <level>      verbose operation


This requires the Windows Offline installation package available from Sun. Note that a particular Java family install package does not remove already installed versions of another Java family, so JRE 1.5 and JRE 1.6 can coexist; all older 1.6 update versions (1.6.0 up to but not including the most recent version) are uninstalled by the following packaging (note that the update version seems to be no more reflected in the last number in the Uninstall ID).

Actually, with Update 10 and later Sun has introduced as default the so called "patch in place" update mechanism (see: http://java.sun.com/javase/6/docs/technotes/guides/jweb/otherFeatures/jre_install.html) which automatically removes the previous version of the same Java family (unless you turned off patch-in-place using the installer). So the line that tries to remove a previously installed Update 10 (msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F83216010FF}) is not strictly necessary (if you installed a 'Family JRE' and not a 'Static JRE').

Patch-in-place sometimes fails with "Error 25099. Unzipping core files failed", returning error code 1603 from msiexec. Sometimes installation will succeed on a later reboot without any intervention, but sometimes it continues to fail. As of December 2010, the root cause is not known, but Sun/Oracle suggests (at http://www.java.com/en/download/help/error_25099.xml) removing %PROGRAMFILES%\Java\jre6 before retrying installation. A fully-automatic workaround requires the ability to execute commands in response to particular error codes and thus may need to take the form of a batch program wrapped around msiexec.

Disable Automatic Update (JRE 6)

JRE 6 Update 18 and Newer

Since approximately 1.6.18 / 6.0 update 18, Sun has included Java Auto Updater as a separate package that is automatically installed with the JRE. You can disable automatic updates by uninstalling the Java Auto Updater after the JRE is installed or upgraded, by adding the following to your package definition:

<install cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />
<upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

JRE 6 on 32-bit Hosts

The following installs the JRE and then removes the "Java Quick Starter" service; if you want to keep "Java Quick Starter" service then just remove the line with "jqs.exe -unregister", but remeber to stop/kill JQS before uninstallation.

<package
  id="java6"
  name="Java Runtime Environment 6"
  revision="%version%"
  reboot="false"
  priority="100">

  <variable name="version" value="38" />

  <check type="uninstall" condition="exists" path="Java(\(TM\))* 6 Update %version%" />

  <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
    <exit code='0' />
    <exit code='1' />
    <exit code='128' />
  </install>
  <install cmd='%SOFTWARE%\jre\jre-6u%version%-windows-i586.exe /s REBOOT=Suppress' />
  <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre6\bin\jqs.exe" "%PROGRAMFILES%\Java\jre6\bin\jqs.exe" -unregister'>
    <exit code='1' />
  </install>
  <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre6\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre6\bin\jqs.exe" -unregister'>
    <exit code='1' />
  </install>
  <install cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' /> <!-- Remove Java Auto Updater software -->
  
  <upgrade include="install" />

  <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F832160%version%FF}' />
</package>

Install JRE6 with EXE

No disrespect to the others who created this script. It was included with the WPKG install, but I edited it to make it more useful in a generic environment. This install 32-bit on both architectures as it is very useful when using both 64 and 32 bit browsers. The 32-bit install is the check type as well. I have tried to annotate as often as possible with comments so the next person using it can further customize it easily. I left a block at the end for misc settings. I like to put the code for turning off Auto-Update there so it runs every time to make sure it doesn't come back.

Note that I have left the uninstall in as a precursor to make sure the correct version is installed. This will allow for later versions to be installed, but this sets a baseline. Others have not used it due to it taking too long. I didn't notice any major delays in my running and editing of this script. Also, I have found that when upgrading to the latest version (43), the uninstall process will hang after the uninstall command for version 39. I'm not sure if this is because of a limit in a buffer or what. I fixed it by moving the initial start up to 15. I have edited the file below to show this change.

Variables:
PKG_VERSION: type in the version of the installer, this will fill in the version number in the installer
PKG_DESTINATION: this is the location of the 32-bit install. Because the program files directory changes depending on architecture, this is necessary to distinguish what type of machine you are installing on.
SOFTWARE: set in the WPKG client install, per best practice

    <package
            id="JRE6"
            name="Java Runtime Environment 6"
            revision="%PKG_VERSION%"
            reboot="false"
            priority="10">

	<!-- Set Variables -->
        <variable name="PKG_VERSION"     value="33" />
        <variable name="PKG_DESTINATION" value="%ProgramFiles(x86)%\Java\jre6\bin" architecture="x64"/>
        <variable name="PKG_DESTINATION" value="%ProgramFiles%\Java\jre6\bin"      architecture="x86"/>

	<!-- Check for uninistall -->
        <check type="uninstall" condition="exists"                path="Java.TM. 6 Update [0-9]+" />
       
	<!-- check install with version -->
        <check type="file"      condition="versiongreaterorequal" path="%PKG_DESTINATION%\java.exe" value="6.0.%PKG_VERSION%" />

	<!-- Begin Install Block --> 

        <!-- stop quick start service -->
        <install cmd="%ComSpec% /c net stop JavaQuickStarterService">
            <exit code="2" />
        </install>
        
	<!-- Set baseline by removing old versions -->
	<!-- remove 32-bit version -->
        <install cmd="%ComSpec% /c for /L %V in (0,1,9) do @msiexec /passive /x {3248F0A8-6813-11D6-A77B-00B0D01600%V0}">
            <exit code="1605" />
        </install>
        <install cmd="%ComSpec% /c for /L %V in (15,1,%PKG_VERSION%) do @msiexec /passive /x {26A24AE4-039D-4CA4-87B4-2F832160%VFF}">
            <exit code="1605" />
        </install>
        
	<!-- remove 64-bit version -->
        <install architecture="x64" cmd="%ComSpec% /c for /L %V in (15,1,%PKG_VERSION%) do @msiexec /passive /x {26A24AE4-039D-4CA4-87B4-2F864160%VFF}">
            <exit code="1605" />
        </install>
        
	<!-- install latest version, only i586 for 32-bit, but install both i586 and x64 on 64-bit systems -->
        <install architecture="x86" cmd='"%SOFTWARE%\Java\jre-6u%PKG_VERSION%-windows-i586.exe" /s /v "/passive /norestart /log %TMP%\JRE6_x86.log ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 REBOOT=Suppress"' />
        <install architecture="x64" cmd='"%SOFTWARE%\Java\jre-6u%PKG_VERSION%-windows-i586.exe" /s /v "/passive /norestart /log %TMP%\JRE6_AMD64.log ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 REBOOT=Suppress"' />
        <install architecture="x64" cmd='"%SOFTWARE%\Java\jre-6u%PKG_VERSION%-windows-x64.exe" /s /v "/passive /norestart /log %TMP%\JRE6_AMD64.log ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 REBOOT=Suppress"' />

	<!-- End Install Block -->
	<!-- Begin upgrade Block -->

        <!-- stop quick start service -->
        <upgrade cmd="%ComSpec% /c net stop JavaQuickStarterService">
            <exit code="2" />
        </upgrade>
       
	<!-- Set baseline by removing old versions -->
	<!-- remove 32-bit version -->
        <upgrade cmd="%ComSpec% /c for /L %V in (0,1,9) do @msiexec /passive /x {3248F0A8-6813-11D6-A77B-00B0D01600%V0}">
            <exit code="1605" />
        </upgrade>
        <upgrade cmd="%ComSpec% /c for /L %V in (15,1,%PKG_VERSION%) do @msiexec /passive /x {26A24AE4-039D-4CA4-87B4-2F832160%VFF}">
            <exit code="1605" />
        </upgrade>
        
	<!-- remove 64-bit version -->
        <upgrade architecture="x64" cmd="%ComSpec% /c for /L %V in (15,1,%PKG_VERSION%) do @msiexec /passive /x {26A24AE4-039D-4CA4-87B4-2F864160%VFF}">
            <exit code="1605" />
        </upgrade>
        
	<!-- upgrade to latest version -->
        <upgrade architecture="x86" cmd='"%SOFTWARE%\Java\jre-6u%PKG_VERSION%-windows-i586.exe" /s /v "/passive /norestart /log %TMP%\JRE6_x86.log ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 REBOOT=Suppress"' />
        <upgrade architecture="x64" cmd='"%SOFTWARE%\Java\jre-6u%PKG_VERSION%-windows-i586.exe" /s /v "/passive /norestart /log %TMP%\JRE6_AMD64.log ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 REBOOT=Suppress"' />
	<upgrade architecture="x64" cmd='"%SOFTWARE%\Java\jre-6u%PKG_VERSION%-windows-x64.exe" /s /v "/passive /norestart /log %TMP%\JRE6_AMD64.log ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 REBOOT=Suppress"' />	

	<!-- End Upgrade Block -->
	<!-- Begin Uninstall Block -->

        <!-- stop quick start service -->
        <remove cmd="%ComSpec% /c net stop JavaQuickStarterService">
            <exit code="2" />
        </remove>
        
	<!-- remove 32-bit version -->
        <remove architecture="x86" cmd="msiexec /passive /x {26A24AE4-039D-4CA4-87B4-2F832160%PKG_VERSION%FF}" />
        <remove architecture="x64" cmd="msiexec /passive /x {26A24AE4-039D-4CA4-87B4-2F832160%PKG_VERSION%FF}" />
        
	<!-- remove 64-bit version -->
        <remove architecture="x64" cmd="msiexec /passive /x {26A24AE4-039D-4CA4-87B4-2F864160%PKG_VERSION%FF}" />

	<!-- End Uninstall Block -->

	<!-- Begin Misc Settings Block -->

	<!-- End Misc Settings Block -->

    </package>

Install JRE 6 with msi without removing old version in a mixed 32-bit/64-bit environment

On 64-bit hosts installing the exe doesn't work: the silent install on a 64-bit host is still looking for the msi in the *System32* directory, so the best thing to do is to install the msi package.

  • jre-6u29-windows-i586.exe is the 32bit installer containing a msi, a cab and some other files.
  • jre-6u29-windows-x64.exe is a 64bit version of the above.

Run the installer without going any further, then find the extracted directory:

  • On Windows XP and possibly others, it extracts to %APPDATA%\Sun\Java\jre1.6.0_29\.
  • On a 32-bit host it extracts to c:\Windows\system32\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.6.0_29\.
  • On a 64-bit host it extracts to c:\Windows\SysWOW64\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.6.0_29\ or C:\Users\username\AppData\LocalLow\Sun\Java\jre1.6.0_29.

Copy the content of the unpacked directory onto your server and install from it.

You should install both 32-bit and 64-bit java on 64-bit machines if you want a 32-bit browser being able to use java.

In this example, no uninstall of the old java versions as it is quite time consuming.

<?xml version="1.0" encoding="UTF-8"?>

<packages>
<!-- jre install with the msi ; for 32-bit and 64-bit hosts -->
<package
    id="jre"
    name="Java(TM) 6 Update 29"
    revision="%version%"
    reboot="false"
    priority="178"
    >
    <variable name="updatever" value="29" />
    <variable name="version" value="6.0.290.11" />
    <variable name="autoupdate" value="0" />

    <check type="logical" condition="or">
        <check
            type="uninstall"
            condition="exists"
            path="Java(TM) 6 Update %updatever%"
            />
        <check
            type="registry"
            condition="equals" 
            path="HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F832160%updatever%FF}\DisplayName"
            value="Java(TM) 6 Update %updatever%"
            />
        <check
            type="file"
            condition="versiongreaterorequal"
            path="%PROGRAMFILES(x86)%\Java\jre6\bin\java.exe"
            value="%version%"
            />
        <check
            type="file"
            condition="versiongreaterorequal"
            path="%PROGRAMFILES%\Java\jre6\bin\java.exe"
            value="%version%"
            />
    </check>

    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
        <exit code='0' />
        <exit code='1' />
        <exit code='128' />
    </install>
    <install
        cmd='msiexec /qn /i %SOFTWARE%\jre\jre1.6.0_%updatever%.msi ADDLOCAL=ALL REBOOT=Suppress IEXPLORER=1 MOZILLA=1 JAVAUPDATE=%autoupdate% CUSTOM=1'
        />
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre6\bin\jqs.exe" "%PROGRAMFILES%\Java\jre6\bin\jqs.exe" -unregister'>
        <exit code='1' />
    </install>
    <install cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre6\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre6\bin\jqs.exe" -unregister'>
        <exit code='1' />
    </install>

    <upgrade cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe' >
        <exit code='0' />
        <exit code='1' />
        <exit code='128' />
    </upgrade>
    <upgrade
        cmd='msiexec /qn /i %SOFTWARE%\jre\jre1.6.0_%updatever%.msi ADDLOCAL=ALL REBOOT=Suppress IEXPLORER=1 MOZILLA=1 JAVAUPDATE=%autoupdate% CUSTOM=1'
        />
    <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre6\bin\jqs.exe" "%PROGRAMFILES%\Java\jre6\bin\jqs.exe" -unregister'>
        <exit code='1' />
    </upgrade>
    <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre6\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre6\bin\jqs.exe" -unregister'>
        <exit code='1' />
    </upgrade>

</package>

<!-- jre 64-bit install with the msi ; for 64-bit hosts only -->
<package
    id="jre-64"
    name="Java(TM) 6 Update 29"
    revision="%version%"
    reboot="false"
    priority="178"
    >
    <variable name="updatever" value="29" />
    <variable name="version" value="6.0.290.11" />
    <variable name="autoupdate" value="0" />

    <check type="logical" condition="or">
        <check
            type="registry"
            condition="equals"
            path="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE"
            value="x86"
            />
        <check
            type="uninstall"
            condition="exists"
            path="Java(TM) 6 Update %updatever% (64-bit)"
            />
        <check
            type="registry"
            condition="equals" path="HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F832160%updatever%FF}\DisplayName"
            value="Java(TM) 6 Update %updatever% (64-bit)"
            />
        <check
            type="file"
            condition="versiongreaterorequal"
            path="%PROGRAMFILES%\Java\jre\bin\java.exe"
            value="%version%"
            />
    </check>
    

    <install cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe'>
        <exit code='0' />
        <exit code='1' />
        <exit code='128' />
    </install>
    <install
        cmd='msiexec /qn /i %SOFTWARE%\jre-64\jre1.6.0_%updatever%.msi ADDLOCAL=ALL REBOOT=Suppress IEXPLORER=1 MOZILLA=1 JAVAUPDATE=%autoupdate% CUSTOM=1'
        />

    <upgrade cmd='taskkill /f /im jqs.exe /im iexplore.exe /im firefox.exe' >
        <exit code='0' />
        <exit code='1' />
        <exit code='128' />
    </upgrade>
    <upgrade
        cmd='msiexec /qn /i %SOFTWARE%\jre-64\jre1.6.0_%updatever%.msi ADDLOCAL=ALL REBOOT=Suppress IEXPLORER=1 MOZILLA=1 JAVAUPDATE=%autoupdate% CUSTOM=1'
        />

</package>

</packages>

JRE 6 Installer Command-line Switches

http://java.sun.com/javase/6/webnotes/install/jre/silent.html gives the following list but it may or may not be complete:

  • /lang=<language ID>, if used, sets the localized language for the installer (see language IDs)
  • /s, if used, specifies a silent installation
  • INSTALLDIR, if used, specifies the drive and path of the installation
  • If INSTALLDIR is not specified, the installation will go into C:\Program Files\java\jre6 (default location).
  • REBOOT=Suppress, if used, indicates that if locked files are encountered the computer should not be rebooted. Most JRE installations will not ask for a reboot.
  • STATIC=1, if used, specifies a static installation. The default is for a Family installation.
  • SYSTRAY=0, if used, if set to zero, Java won't show an systray icon when loaded.

The following switches are deprecated for JRE 6 Update 10 and higher:

  • IEXPLORER=1
  • MOZILLA=1
  • ADDLOCAL=ALL
  • JAVAUPDATE=0
  • JU=0
  • AUTOUPDATECHECK=0

From the 'Java SE 6 Update 10 Release Notes': "Windows Regression when Using MSI Install Options

On Windows XP Pro SP3 (32bits), when installing JRE 6u10 or later and using MSI install options /qb or /passive, installation fails with Error 1606.Could not access network location 0.. The workaround is to not use the /qb or /passive options. Options that work correctly are /q, /qn (no UI), /qr (reduced UI), and /quiet (quiet mode, no user interaction). See 6764967 for details."

Older Versions

Uninstalling Old Versions

To uninstall the old Java 7 and 8 versions you can use a a removal package.

Older versions of Java did not uninstall themselves when new versions were installed. These older versions can pose a security risk even with newer versions installed. Older versions should be uninstalled unless they are required for some reason. Attempting to uninstall every old version of Java in the package definition can be very slow. Only include these uninstall commands in your package definition if there is a possibility that clients will have the older Java versions.

The patch-in-place mechanism was introduced in JRE 6 Update 10, so only versions before that need to be uninstalled.

  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142000}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142010}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142020}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142030}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142040}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142050}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142060}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142070}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142080}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142090}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142100}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142110}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142120}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142130}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142140}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142150}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142160}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150090}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150100}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150110}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150120}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150130}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150140}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160000}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160010}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160020}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160030}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160040}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160050}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160060}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160070}'><exit code='0' /><exit code='1605' /></install>

  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142000}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142010}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142020}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142030}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142040}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142050}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142060}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142070}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142080}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142090}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142100}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142110}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142120}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142130}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142140}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142150}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {7148F0A8-6813-11D6-A77B-00B0D0142160}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150090}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150100}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150110}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150120}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150130}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0150140}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160000}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160010}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160020}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160030}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160040}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160050}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160060}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /norestart /x {3248F0A8-6813-11D6-A77B-00B0D0160070}'><exit code='0' /><exit code='1605' /></upgrade>

Disable Automatic Update - older versions

Automatic updates can be disabled with JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0; if these command line switches should not work for you, then you can alter the registry (read Adding Registry Settings for that) to disable autoupdate:

[HKEY_CURRENT_USER\Software\JavaSoft\Java Update\Policy]
"EnableAutoUpdateCheck"=hex:01,00,00,00,d0,8c,9d,df,01,15,d1,11,8c,7a,00,c0,4f,\
  c2,97,eb,01,00,00,00,95,1a,3a,6a,da,1d,56,49,9d,23,dc,0e,e8,f5,97,62,00,00,\
  00,00,1c,00,00,00,50,00,61,00,73,00,73,00,77,00,6f,00,72,00,64,00,20,00,44,\
  00,61,00,74,00,61,00,00,00,03,66,00,00,a8,00,00,00,10,00,00,00,bc,f0,2a,6f,\
  bb,65,46,e7,e3,c5,06,5e,21,cc,8b,35,00,00,00,00,04,80,00,00,a0,00,00,00,10,\
  00,00,00,67,0c,e5,4a,75,25,eb,4b,33,5a,4a,27,c9,5a,28,39,08,00,00,00,b3,b9,\
  a2,ba,f1,81,be,10,14,00,00,00,bd,52,6a,9e,b3,e7,dd,06,89,b1,74,32,0b,e8,25,\
  ac,4b,64,1b,99

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy]
"EnableAutoUpdateCheck"=dword:00000000
"EnableJavaUpdate"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"SunJavaUpdateSched"=-

Another way to bypass Automatic Update is to use the MSI Installer. According to http://www.java.com/en/download/help/msi_install.xml you can 'extract' the MSI Package and pass the options as mentioned above (JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0). Worked fine for me with 1.6.18.

<install cmd='MsiExec.exe /qn /i "%SOFTWARE%\Java1.6\jre1.6.0_18.msi" ADDLOCAL=ALL REBOOT=Suppress JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0'/>

Java Runtime Environment (JRE) 6 Update 10

Sun has skipped 2 update versions and has released Update 10 as the versions replacing Update 7. Update 10 introduced some substantial changes, also in relation to the installation/uninstallation process we manage with WPKG: specifically it introduced a new binary "jqs.exe" and a service called "Java Quick Starter" starting it automatically at boot time.

Java Runtime Environment (JRE) 6 Update 7

This requires the Windows Offline installation package available from Sun. Note that the Java install package does not replace old versions, so JRE 1.5 and JRE 1.6 can coexist; all older 1.6 update versions (1.6.0 up to 1.6.0 Update 6) are tried to be removed (note that the update version is reflected in the last number in the Uninstall ID). Notice how the path string in the uninstall check has changed from previous version.

For the JDK, just change "jre" to "jdk" in the setup program's name and change "A77B" to "A78A" in the Uninstall ID.

For the JDK, we had to replace {3248F0A8-6813-11D6-A77B- with {32A3A4F4-B792-11D6-A78A-. This works and tested with Java6u7

 <package id="java6" name="Java Runtime Environment 6 Update 7" revision="7" reboot="false" priority="100">
  <check type="uninstall" condition="exists" path="Java(TM) 6 Update 7" />
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160000}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160010}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160020}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160030}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160040}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160050}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160060}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='%SOFTWARE%\jre\jre-6u7-windows-i586-p.exe /s IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Suppress JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0' />
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160000}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160010}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160020}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160030}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160040}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160050}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160060}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='%SOFTWARE%\jre\jre-6u7-windows-i586-p.exe /s IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Suppress JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0' />
  <remove cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0160070}' />
 </package>


Installer Command-line Switches

  • IEXPLORER=1 - install plugin into Internet Explorer
  • MOZILLA=1 - install plugin into Mozilla browsers such as Firefox
  • ADDLOCAL=ALL
  • JAVAUPDATE=0 - disable auto updates but this behaviour changed during the 6.0 to 6.0 Update 7 releases
  • JU=0 - disable auto updates but this behaviour changed during the 6.0 to 6.0 Update 7 releases
  • AUTOUPDATECHECK=0 - disable auto updates but this behaviour changed during the 6.0 to 6.0 Update 7 releases
  • INSTALLDIR= - specify installation directory

Automatic updates can be disabled with JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0; if these command line switches should not work for you, then you can alter the registry (read Adding Registry Settings for that) to disable autoupdate:

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy]
"EnableAutoUpdateCheck"=dword:00000000
"EnableJavaUpdate"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"SunJavaUpdateSched"=-