Difference between revisions of "Java"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
(Added a note about judging which is the stable version)
(Restore Java 6 info, still needs to be updated for 6u27)
Line 240: Line 240:
 
<upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />
 
<upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />
 
</source>
 
</source>
 +
 +
=Java Runtime Environment (JRE) 6=
 +
 +
==Installer Versions==
 +
 +
There are various versions of the installer:
 +
 +
* Those from http://www.oracle.com/technetwork/java/javase/downloads/index.html which are aimed at developers or ISVs. We want the 'Windows Offline Installation' version with a filename of jre-6u##-windows-i586.exe.
 +
 +
* 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.
 +
 +
==Uninstalling Old Versions==
 +
 +
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.
 +
 +
<source lang="xml">
 +
  <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>
 +
</source>
 +
 +
==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.
 +
 +
<source lang="xml">
 +
<install cmd='net STOP JavaQuickStarterService' >
 +
  <exit code='2' />
 +
</install>
 +
</source>
 +
 +
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 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:
 +
 +
<source lang="xml">
 +
<install cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />
 +
<upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />
 +
</source>
 +
 +
=== 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:
 +
 +
<source lang="reg">
 +
[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"=-
 +
</source>
 +
 +
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.
 +
 +
<source lang="xml">
 +
<install cmd='MsiExec.exe /qn /i "%SOFTWARE%\Java1.6\jre1.6.0_18.msi" ADDLOCAL=ALL REBOOT=Suppress JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0'/>
 +
</source>
 +
 +
== JRE 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.
 +
 +
<source lang="xml">
 +
<package
 +
  id="java6"
 +
  name="Java Runtime Environment 6"
 +
  revision="%version%"
 +
  reboot="false"
 +
  priority="100">
 +
 +
  <variable name="version" value="26" />
 +
 +
  <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}' />
 +
 
 +
  <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='%SOFTWARE%\jre\jre-6u%version%-windows-i586.exe /s REBOOT=Suppress' />
 +
  <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>
 +
  <upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />
 +
 +
  <remove cmd='msiexec /qn /x {26A24AE4-039D-4CA4-87B4-2F832160%version%FF}' />
 +
</package>
 +
</source>
 +
 +
==Install JRE 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-6u26-windows-i586.exe is the 32bit installer containing a msi, a cab and some other files.
 +
* jre-6u26-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_26\.
 +
* On a 32-bit host it extracts to c:\Windows\system32\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.6.0_26\.
 +
* On a 64-bit host it extracts to c:\Windows\SysWOW64\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.6.0_26\.
 +
 +
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.
 +
 +
<source lang="xml">
 +
 +
<?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 26"
 +
    revision="%version%"
 +
    reboot="false"
 +
    priority="178"
 +
    >
 +
    <variable name="updatever" value="26" />
 +
    <variable name="version" value="6.0.260.3" />
 +
    <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 26"
 +
    revision="%version%"
 +
    reboot="false"
 +
    priority="178"
 +
    >
 +
    <variable name="updatever" value="26" />
 +
    <variable name="version" value="6.0.260.3" />
 +
    <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>
 +
</source>
 +
 +
== 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 [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6764967 6764967] for details."
  
 
=Older Versions=
 
=Older Versions=

Revision as of 16:10, 24 August 2011

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. There are many variations on Sun's (now Oracle's) JRE, in particular this page 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 release. 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.0u27. 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) 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 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="00" />

  <check type="logical" condition="or">
      <check type="uninstall" condition="exists" path="Java(TM) 7 Update %version%" />
      <check type="uninstall" condition="exists" path="Java(TM) 7" />
  </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='%SOFTWARE%\jre\jre-7u%version%-windows-i586.exe /s REBOOT=Suppress IEXPLORER=1 MOZILLA=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='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

  <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='%SOFTWARE%\jre\jre-7u%version%-windows-i586.exe /s REBOOT=Suppress IEXPLORER=1 MOZILLA=1' />
  <!-- remove Java Quick Starter -->
  <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
    <exit code='1' />
  </upgrade>
  <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" -unregister'>
    <exit code='1' />
  </upgrade>
  <!-- Remove Java Auto Updater software -->
  <upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

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

</package>

Install JRE 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 %APPDATA%\Sun\Java\jre1.7\.
  • On Windows 7, it extracts to c:\Users\username\AppData\LocalLow\Sun\Java\jre1.7.0_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="00" />
    <variable name="version" value="7.0.0.147" />
    <variable name="autoupdate" value="0" />

    <check type="logical" condition="or">
        <check
            type="uninstall"
            condition="exists"
            path="Java(TM) 7 Update %updatever%"
            />
        <check
            type="uninstall"
            condition="exists"
            path="Java(TM) 7"
            />
    </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.7.0_u%updatever%.msi REBOOT=Suppress IEXPLORER=1 MOZILLA=1 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='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />


    <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.7.0_u%updatever%.msi REBOOT=Suppress IEXPLORER=1 MOZILLA=1 JAVAUPDATE=%autoupdate% CUSTOM=1'
        />
    <!-- remove Java Quick Starter -->
    <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='1' />
    </upgrade>
    <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='1' />
    </upgrade>
    <!-- Remove Java Auto Updater software -->
    <upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

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

</package>

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

    <check type="logical" condition="or">
        <check
            type="uninstall"
            condition="exists"
            path="Java(TM) 7 Update %updatever% (64-bit)"
            />
        <check
            type="uninstall"
            condition="exists"
            path="Java(TM) 7 (64-bit)"
            />
    </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.7.0_u%updatever%.msi REBOOT=Suppress IEXPLORER=1 MOZILLA=1 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='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

    <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.7.0_u%updatever%.msi REBOOT=Suppress IEXPLORER=1 MOZILLA=1 JAVAUPDATE=%autoupdate% CUSTOM=1'
        />
    <!-- remove Java Quick Starter -->
    <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='1' />
    </upgrade>
    <upgrade cmd='%COMSPEC% /C if exist "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" "%PROGRAMFILES(x86)%\Java\jre7\bin\jqs.exe" -unregister'>
      <exit code='1' />
    </upgrade>
    <!-- Remove Java Auto Updater software -->
    <upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

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

</package>

</packages>

Disable Automatic Update

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}' />

Java Runtime Environment (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.

Uninstalling Old Versions

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>

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 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}' />

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'/>

JRE 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="26" />

  <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}' />
  
  <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='%SOFTWARE%\jre\jre-6u%version%-windows-i586.exe /s REBOOT=Suppress' />
  <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>
  <upgrade cmd='msiexec /qn /x {4A03706F-666A-4037-7777-5F2748764D10}' />

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

Install JRE 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-6u26-windows-i586.exe is the 32bit installer containing a msi, a cab and some other files.
  • jre-6u26-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_26\.
  • On a 32-bit host it extracts to c:\Windows\system32\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.6.0_26\.
  • On a 64-bit host it extracts to c:\Windows\SysWOW64\config\systemprofile\AppData\LocalLow\Sun\Java\jre1.6.0_26\.

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 26"
    revision="%version%"
    reboot="false"
    priority="178"
    >
    <variable name="updatever" value="26" />
    <variable name="version" value="6.0.260.3" />
    <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 26"
    revision="%version%"
    reboot="false"
    priority="178"
    >
    <variable name="updatever" value="26" />
    <variable name="version" value="6.0.260.3" />
    <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>

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

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>

Java Quick Starter instructions for JRE version 6

"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 using versions older than JRE 7 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.

Installer Command-line Switches

http://java.sun.com/javase/6/webnotes/install/jre/silent.html gives the following list for Java version 6 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."

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"=-


J2SE Runtime Environment 5.0 Update 11

There are two versions of the installer:

This requires the Windows Offfline installation package available from Sun. Note that the java install package does not replace old versions, so to accomplish a true upgrade, remove commands are required for the install/upgrade process.

<package id="java" name="Java Runtime Environment 1.5.0_11" revision="4" reboot="false" priority="0">
  <check type="uninstall" condition="exists" path="J2SE Runtime Environment 5.0 Update 11" />
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150090}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150100}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='%SOFTWARE%\jre\jre-1_5_0_11-windows-i586-p.exe /s /v" /qn IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Supress JAVAUPDATE=0' />
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150090}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150100}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='%SOFTWARE%\jre\jre-1_5_0_11-windows-i586-p.exe /s /v" /qn IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Supress JAVAUPDATE=0' />
  <remove cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150110}' />
</package>

J2SE Runtime Environment 5.0 Update 10

This requires the Windows Offfline installation package available from Sun. Note that the java install package does not replace old versions, so to accomplish a true upgrade, remove commands are required for the install/upgrade process.

Note that the class id of the remove section was incorrect in an early edition of this page - the last 3 digits should be 100, not 010.

<package id="java" name="Java Runtime Environment 1.5.0_10" revision="3" reboot="false" priority="0">
  <check type="uninstall" condition="exists" path="J2SE Runtime Environment 5.0 Update 10" />
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150090}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='%SOFTWARE%\jre\jre-1_5_0_10-windows-i586-p.exe /s /v" /qn IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Supress JAVAUPDATE=0' />
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150090}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='%SOFTWARE%\jre\jre-1_5_0_10-windows-i586-p.exe /s /v" /qn IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Supress JAVAUPDATE=0' />
  <remove cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150100}' />
</package>

J2SE Runtime Environment 5.0 Update 9

This requires the Windows Offfline installation package available from Sun. Note that the java install package does not replace old versions, so to accomplish a true upgrade, remove commands are required for the install/upgrade process.


<package id="jre" name="Java Runtime Environment 1.5.0_9" revision="2" reboot="false" priority="0">
  <check type="uninstall" condition="exists" path="J2SE Runtime Environment 5.0 Update 9" />
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></install>
  <install cmd='%SOFTWARE%\java\jre-1_5_0_09-windows-i586-p.exe /s /v" /qn IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Supress JAVAUPDATE=0' />
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150000}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150010}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150020}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150030}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150040}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150050}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150060}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150070}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150080}'><exit code='0' /><exit code='1605' /></upgrade>
  <upgrade cmd='%SOFTWARE%\java\jre-1_5_0_09-windows-i586-p.exe /s /v" /qn IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Supress JAVAUPDATE=0' />
  <remove cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150090}' />
</package>

J2SE Runtime Environment 5.0 Update 6

This requires the Windows Offline installation package available from Sun.

<package id="jre" name="Java Runtime Environment 1.5.0_6" revision="1" reboot="true" priority="0">
 <check type="uninstall" condition="exists" path="J2SE Runtime Environment 5.0 Update 6" />
 <install cmd='%WINDIR%\system32\cmd /c start /wait /d %SOFTWARE%\java %SOFTWARE%\java\jre-1_5_0_06-windows-i586-p.exe /s /v" /qn IEXPLORER=1 MOZILLA=1 ADDLOCAL=ALL REBOOT=Supress JAVAUPDATE=0' />
 <remove cmd='msiexec /qn /x {3248F0A8-6813-11D6-A77B-00B0D0150060}' />
</package>

Other Useful MSI Properties

This will install java with no updating and no icons:

jre-1_5_0_10-windows-i586-p.exe /s /v"/qn ADDLOCAL=ALL AUTOUPDATECHECK=0 JU=0 IEXPLORER=1 MOZILLA=1 WEBSTARTICON=0 SYSTRAY=0 REBOOT=Suppress JAVAUPDATE=0 EULA=1"

Further Details

J2SE Runtime Environment 5.0 Update 5

First download the EXE package from java.sun.com, install it, and find an MSI package on your drive. Then use this MSI to distribute Java to other machines.

Note: When you use the *.exe file directly with command line switches as proposed by sun the installer waits forever for someone accepting the licence agreement.

Note that "install cmd" should be in one line; it was wrapped because it was too long to fit here!

 <package
     id="jre"
     name="Java Runtime Environment 1.5.0_05"
     revision="1"
     reboot="true"
     priority="9">
     <check type="uninstall" condition="exists" path="J2SE Runtime Environment 5.0 Update 5" />
     <install cmd='msiexec /q /i %SOFTWARE%\Java\jre1.5.0_05.msi allusers=1 REBOOT=Suppress CUSTOM=1 IEXPLORER=1 MOZILLA=1 NETSCAPE6=1 JAVAUPDATE=0 ADDLOCAL=ALL' />
     <remove  cmd='MsiExec.exe /q /x{3248F0A8-6813-11D6-A77B-00B0D0150050}' />
 </package>

 <package
     id="jdk"
     name="Java Development Kit 1.5.0_05"
     revision="1"
     reboot="true"
     priority="9">
     <check type="uninstall" condition="exists" path="J2SE Development Kit 5.0 Update 5" />
     <install cmd='msiexec /q /i %SOFTWARE%\Java\jdk1.5.0_05.msi allusers=1 REBOOT=Suppress CUSTOM=1 IEXPLORER=1 MOZILLA=1 NETSCAPE6=1 JAVAUPDATE=0 ADDLOCAL=ALL' />
     <remove  cmd='MsiExec.exe /q /x{32A3A4F4-B792-11D6-A78A-00B0D0150050}' />
 </package>

Alternate Java 6 (JRE/SDK) Installer (seems very complicated)

This is my personal solution. Works properly for me starting from Java 6 Update 11. It works on Windows XP and Vista. 64-bit OS is supported as well as 32-bit OS. It also seems that Sun is not going to install each Java update into an independent directory. This will hopefully eliminate the need to uninstall previous versions manually.

Download

First of all download the offline installers. Do not download the new Online installers. It might work as well but I did not try it. After download you should have the following files (or a subset of it):

  • jdk-6u11-windows-i586-p.exe
  • jdk-6u11-windows-x64.exe
  • jre-6u11-windows-i586-p.exe
  • jre-6u11-windows-x64.exe

If you just deploy JRE, then you do not need to download the JDK packages. Similarly you do not need the x64 packages if you deploy to 32-bit OS only.

Prepare installation

Unfortunately the .exe installers do not always work silently when the "/v/qn..." switch is used. On 64-bit OS it might yield a "package not found" error in silent installation. That's why I recommend to pre-extract the packages.

  1. Run the installer as usual (e.g. double-click "jdk-6u10-windows-i586-p.exe"
  2. Get the extracted installer from "%AppData%\Sun\Java\" ("%LocalAppData%\..\LocalLow\Sun\Java" in Vista) and copy them to the package deployment folder. Do this for all packages you like to deploy. Here's a sample how my directory structure looks after extracting and copying:
    • JavaSE/install.cmd
    • JavaSE/jdk1.6.0_11_32/jdk-6u11-windows-i586-p.exe
    • JavaSE/jdk1.6.0_11_32/jdk1.6.0_11.msi
    • JavaSE/jdk1.6.0_11_32/sb160110.cab
    • JavaSE/jdk1.6.0_11_32/sd160110.cab
    • JavaSE/jdk1.6.0_11_32/sj160110.cab
    • JavaSE/jdk1.6.0_11_32/sp160110.cab
    • JavaSE/jdk1.6.0_11_32/sr160110.cab
    • JavaSE/jdk1.6.0_11_32/ss160110.cab
    • JavaSE/jdk1.6.0_11_32/st160110.cab
    • JavaSE/jdk1.6.0_11_32/sz160110.cab
    • JavaSE/jdk1.6.0_11_x64/jdk-6u11-windows-x64.exe
    • JavaSE/jdk1.6.0_11_x64/jdk-6u11-windows-x64.msi
      • Note: This installer seems to be different from all the others. It uses a different package format and extracts to "%TEMP%\<UID>". So you have to grab the MSI file from there.
    • JavaSE/jre1.6.0_11_32/Data1.cab
    • JavaSE/jre1.6.0_11_32/jre-6u11-windows-i586-p.exe
    • JavaSE/jre1.6.0_11_32/jre1.6.0_11.msi
    • JavaSE/jre1.6.0_11_x64/Data1.cab
    • JavaSE/jre1.6.0_11_x64/jre-6u11-windows-x64.exe
    • JavaSE/jre1.6.0_11_x64/jre.msi
      • Note: I had to rename the msi file from "jre1.6.0_10.msi" to "jre.msi" in order to install properly. Without this fix it failed with a message that it could not locate "jre.msi". Seems to be a bug within the msi package.
    • JavaSE/unattended-jdk-uninstall.cmd
    • JavaSE/unattended-jdk.cmd
    • JavaSE/unattended-jre-uninstall.cmd
    • JavaSE/unattended-jre.cmd

Please NOTE: There are some *.cmd scripts listed which I use as install scripts. The scripts are listed within the following chapters.

Package definition

<?xml version="1.0" encoding="utf-8" ?>
<packages>

<package id='JRE' name='Java runtime environment' revision='16010' priority='50' reboot='false' >
  <!-- Java runtime environment -->
  <check type='logical' condition='or'>
  <check type='uninstall' condition='exists' path='Java(TM) 6 Update 11' />
  <check type='uninstall' condition='exists' path='Java(TM) 6 Update 11 (64-bit)' />
  </check>
  <install cmd='"%SOFTWARE%\JavaSE\unattended-jre.cmd"' />
  <remove cmd='"%SOFTWARE%\JavaSE\unattended-jre-uninstall.cmd"' />
  <upgrade cmd='"%SOFTWARE%\JavaSE\unattended-jre.cmd"' />
</package>

</packages>

As you can see the package just runs the unattended* cmd script which will make sure the right packages for the currently running operating system is executed.

NOTE: This package definition is for JRE installation. If you would like to deploy JDK, then just refer to unattended-jdk* scripts insted.

The scripts

As listed above there are some scripts required. And here they come...

NOTE: The unattended* scripts are basically identical for all versions - they just need to list the correct MSI file within the header (PKG32 and PKG64 variables).

unattended-jre.cmd / unattended-jre-uninstall.cmd (both files are identical, you might also link them on Unix/Linux level).

@echo off

REM Get MSI file by executing installation and then grab tje MSI file from
REM the %LocalAppData%\..\LocalLow\Sun\Java folder

set PKG32=jre1.6.0_11_32\jre1.6.0_11.msi
set PKG64=jre1.6.0_11_x64\jre.msi
set EXIT_CODE=0

set INSTALLER=install.cmd

echo Applying Java Runtime

REM Determine aciton
if "%~nx0" == "unattended-jre-uninstall.cmd" (
  if not "%ProgramFiles(x86)%" == "" (
    goto 64bituninstall
  ) else (
    goto 32bituninstall
  )
)

if not "%ProgramFiles(x86)%" == "" goto 64bitinstall
goto 32bitinstall

:64bitinstall
echo Installing 64bit edition
call "%~dp0%INSTALLER%" msiinstall "%PKG32%" "%PKG64%" "" "/qn /norestart IEXPLORER=1 NETSCAPE6=0 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=0 WEBSTARTICON=0"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
REM Install 32-bit version as well - used by 32-bit applications
call "%~dp0%INSTALLER%" msiinstall "%PKG32%" "%PKG32%" "" "/qn /norestart IEXPLORER=1 NETSCAPE6=0 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=0 WEBSTARTICON=0"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end

:64bituninstall
echo Uninstalling 64bit edition
call "%~dp0%INSTALLER%" msiuninstall "%PKG32%" "%PKG64%"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
REM Uninstall 32-bit version as well - used by 32-bit applications
call "%~dp0%INSTALLER%" msiuninstall "%PKG32%" "%PKG32%"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end


:32bitinstall
echo Installing 32bit edition
call "%~dp0%INSTALLER%" msiinstall "%PKG32%" "%PKG64%"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end

:32bituninstall
echo Uninstalling 32bit edition
call "%~dp0%INSTALLER%" msiuninstall "%PKG32%" "%PKG64%"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end


:end
exit /B %EXIT_CODE%

unattended-jdk.cmd / unattended-jdk-uninstall.cmd (both files are identical, you might also link them on Unix/Linux level).

@echo off

REM Get MSI file by executing installation and then grab tje MSI file from
REM the %LocalAppData%\..\LocalLow\Sun\Java folder

set PKG32=jdk1.6.0_10_32\jdk1.6.0_11.msi
set PKG64=jdk1.6.0_10_x64\jdk-6u11-windows-x64.msi
set EXIT_CODE=0

set INSTALLER=install.cmd

echo Applying Java Runtime

REM Determine aciton
if "%~nx0" == "unattended-jdk-uninstall.cmd" (
  if not "%ProgramFiles(x86)%" == "" (
    goto 64bituninstall
  ) else (
    goto 32bituninstall
  )
)

if not "%ProgramFiles(x86)%" == "" goto 64bitinstall
goto 32bitinstall

:64bitinstall
echo Installing 64bit edition
call "%~dp0%INSTALLER%" msiinstall "%PKG32%" "%PKG64%" "" "/qn /norestart IEXPLORER=1 NETSCAPE6=0 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=0 WEBSTARTICON=0"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
REM Install 32-bit version as well - used by 32-bit applications
call "%~dp0%INSTALLER%" msiinstall "%PKG32%" "%PKG32%" "" "/qn /norestart IEXPLORER=1 NETSCAPE6=0 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=0 WEBSTARTICON=0"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end

:64bituninstall
echo Uninstalling 64bit edition
call "%~dp0%INSTALLER%" msiuninstall "%PKG32%" "%PKG64%"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
REM Uninstall 32-bit version as well - used by 32-bit applications
call "%~dp0%INSTALLER%" msiuninstall "%PKG32%" "%PKG32%"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end


:32bitinstall
echo Installing 32bit edition
call "%~dp0%INSTALLER%" msiinstall "%PKG32%" "%PKG64%" "" "/qn /norestart IEXPLORER=1 NETSCAPE6=0 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=0 WEBSTARTICON=0"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end

:32bituninstall
echo Uninstalling 32bit edition
call "%~dp0%INSTALLER%" msiuninstall "%PKG32%" "%PKG64%"
if %ERRORLEVEL% GTR %EXIT_CODE% set EXIT_CODE=%ERRORLEVEL%
goto end


:end
exit /B %EXIT_CODE%

As you can see the script is mainly used to determine the correct installer for 32- or 64-bit operating system.

NOTE: I am installing 32-bit version on 64-bit OS as well. This assures that 32-bit browsers can run the Java plug-in too.

Due to the fact that lots of installers are using always the same silent switches I prepared a generic "install.cmd" script. So I can just pass the installer filename and the type of installer as parameters and I do not have to care about the switches each time. So here it comes:

@echo off

REM Usage:
REM msiinstall.cmd <type> <32-bit-installer> <64-bit-installer> [installer-location [custom-options]]
REM where type is one of
REM     msiinstall     Install the given MSI package
REM     msiuninstall   Uninstall the given MSI package
REM     innosetup      Inno setup
REM     installshield  Install shield
REM     nsis           Nullsoft install system (NSIS)
REM     custom         Custom installer - options required in this case
REM 32-bit-installer   Full file name (including extension) of 32-bit installer
REM 64-bit-installer   Full file name (including extension) of 64-bit installer
REM installer-location Path where the installers are stored, if empty assumes directory where install.cmd is
REM custom-options     Replace the default installer options with the ones given

REM Global variables
set INSTALL_CMD=
set EXIT_CODE=0

REM Get command type
set TYPE=%~1

REM Get 32-bit installer name
set CMD32=%~2

REM Get 64-bit installer name
set CMD64=%~3

REM get file path
set INSTALLER_PATH=%~dp0
if not "%~4" == "" (
set INSTALLER_PATH=%~4
)

set OPTIONS=
if not "%~5" == "" (
set OPTIONS=%~5
)

REM Detect which system is used
if not "%ProgramFiles(x86)%" == "" goto 64bit
goto 32bit


REM ##########################################################################
REM 64-bit system detected
REM ##########################################################################
:64bit
REM Determine 64-bit installer to be used
echo 64-bit system detected.
REM set INSTALLER64=
if not "%CMD64%" == "" (
set INSTALLER64=%CMD64%
) else (
REM Use 32-bit installer if available, no 64-bit installer available.
if not "%CMD32%" == "" (
echo Using 32-bit installer, no 64-bit installer specified.
set INSTALLER64=%CMD32%
) else (
echo Neither 64-bit nor 32-bit installer specified. Exiting.
goto usage
)
)

REM Check if installer is valid
if exist "%INSTALLER_PATH%%INSTALLER64%" (
set INSTALL_CMD=%INSTALLER_PATH%%INSTALLER64%
) else (
echo Installer "%INSTALLER_PATH%%INSTALLER64%" cannot be found! Exiting.
exit /B 97
)
goto installerselection


REM ##########################################################################
REM 32-bit system detected
REM ##########################################################################
:32bit
REM Determine 32-bit installer to be used
echo 32-bit system detected.
set INSTALLER32=
if not "%CMD32%" == "" (
set INSTALLER32=%CMD32%
) else (
echo No 32-bit installer specified. Exiting.
exit /B 96
)


REM Check if installer is valid
if exist "%INSTALLER_PATH%%INSTALLER32%" (
set INSTALL_CMD=%INSTALLER_PATH%%INSTALLER32%
) else (
echo Installer "%INSTALLER_PATH%%INSTALLER32%" cannot be found! Exiting.
exit /B 95
)
goto installerselection



REM ##########################################################################
REM select installer system
REM ##########################################################################
:installerselection
if /i "%TYPE%" == "msiinstall"    goto msiinstaller
if /i "%TYPE%" == "msiuninstall"  goto msiuninstaller
if /i "%TYPE%" == "innosetup"     goto innoinstaller
if /i "%TYPE%" == "installshield" goto installshieldinstaller
if /i "%TYPE%" == "nsis"          goto nsisinstaller
if /i "%TYPE%" == "custom"        goto custominstaller
goto usage



:msiinstaller
echo Installing "%INSTALL_CMD%"
if "%OPTIONS%" == "" (
set OPTIONS=/qn /norestart
)
start /wait "Software installation" msiexec /i"%INSTALL_CMD%" %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:msiuninstaller
echo Uninstalling "%INSTALL_CMD%"
if "%OPTIONS%" == "" (
set OPTIONS=/qn /norestart
)
start /wait "Software uninstallation" msiexec /x "%INSTALL_CMD%" %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:innoinstaller
echo Installing "%INSTALL_CMD%"
REM if "%OPTIONS%" == "" (
REM set OPTIONS=/verysilent /norestart /sp-
REM )
start /wait "Software installation" "%INSTALL_CMD%" /verysilent /norestart /sp- %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:installshieldinstaller
echo Installing "%INSTALL_CMD%"
start /wait "Software installation" "%INSTALL_CMD%" /s %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end


:nsisinstaller
echo Installing "%INSTALL_CMD%"
start /wait "Software installation" "%INSTALL_CMD%" /S %OPTIONS%
set EXIT_CODE=%ERRORLEVEL%
goto end

:custominstaller
if "%OPTIONS%" == "" goto usage
echo Installing "%INSTALL_CMD%"
start /wait "Software installation" "%INSTALL_CMD%" %OPTIONS%
set EXIT_CODE=%ERRORLEEL%
goto end

:usage
echo Usage:
echo "%~nx0 <type> <32-bit-installer> <64-bit-installer> [installer-location [custom-options]]"
echo where type is one of
echo     msiinstall        Install the given MSI package
echo     msiuninstall      Uninstall the given MSI package
echo     innosetup         Inno setup
echo     installshield     Install shield
echo     nsis              Nullsoft install system (NSIS)
echo     custom            Custom installer - options required in this case
echo 32-bit-installer      Full file name (including extension) of 32-bit installer
echo 64-bit-installer      Full file name (including extension) of 64-bit installer
echo installer-location    Path where the installers are stored
echo custom-options        Replace the default installer options with the ones given
exit /B 99

:end
exit /B %EXIT_CODE%

That's it. This framework is quite easy to re-use for upgrades. The only thing you have to do is to download the Java Offline installers for the edition you like to deploy, then extract it, put the files to a sub-folder of the scripts (see directory structure outlined above) and then change the PKG32 and PKG64 paths on top of the scripts accordingly.

Java Uninstall Method

If you are just starting out with WPKG and want to be able to uninstall all versions of Java prior to your first package, you can use JavaRa (http://raproducts.org/javara.html) to silently uninstall all prior versions of the JRE.

There's also a scripting solution. It can also be used for other programs like Adobe Reader.

@ECHO OFF
rem Find all programs installed on the computer
ECHO Finding all Java-installations...
FOR /f %%I IN ('REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall') DO ECHO %%I | FIND "{" > NUL && CALL :All-Installations %%I
ECHO Finished removing Java.
GOTO :EOF

:All-Installations
rem Filter out all but the Sun Installations
FOR /f "tokens=2*" %%T IN ('REG QUERY %1 /v Publisher 2^> NUL') DO ECHO Removing: %%U | FIND "Sun" > NUL && CALL :Sun-Installations %1
GOTO :EOF
:Sun-Installations
rem Filter out all but the Sun-Java Installations. Note the tilde + n, which drops all the subkeys from the path
FOR /f "tokens=2*" %%T IN ('REG QUERY %1 /v DisplayName 2^> NUL') DO ECHO Removing: %%U | FIND "Java" && CALL :Sun-Java-Installs %~n1
GOTO :EOF
:Sun-Java-Installs
rem Run uninstaller in unattended mode
START "" /WAIT "%WinDir%\SYSTEM32\msiexec.exe" /x%1 /qn
GOTO :EOF

Here's a JScript variant using the MSI ActiveX object. Execute it with cscript. Any JRE from 1.4.2 up to including 1.6u7 will be removed:

var msi = new ActiveXObject("WindowsInstaller.Installer");
msi.UILevel = 2; // INSTALLUILEVEL_NONE
var products = msi.Products;
for (var i = 0; i < products.Count; ++i)
    if (products.Item(i).match(/^\{(?:7148F0A8-6813-11D6-A77B-00B0D0142|3248F0A8-6813-11D6-A77B-00B0D01[56])/))
        msi.ConfigureProduct(products.Item(i), 0, 2 /* INSTALLSTATE_ABSENT */);

And here is a VBS equivalent

Set msi = CreateObject("WindowsInstaller.Installer")
Set re = new regexp 
Const msiInstallStateAbsent = 2

re.pattern="{(" & _
				"7148F0A8-6813-11D6-A77B-00B0D0142" & _
				"|3248F0A8-6813-11D6-A77B-00B0D01[56]" & _
				")}"

msi.UILevel = 2 

For Each msipackage In msi.Products
	info = msipackage & " = " & msi.ProductInfo(msipackage, "ProductName")
	WScript.Echo(Info)
Next

For Each msipackage In msi.Products
	if re.test(msipackage) Then
		WScript.Echo("Uninstalling " +msipackage)
		msi.ConfigureProduct msipackage, 0, msiInstallStateAbsent
	End If
Next


See also Sun Java