13

We want to update the JDK environment on multiple machines, all running windows but different versions (either XP or 7)

For that purpose, I'm now creating a script which will automatically run the correct installer (32/64 bit). I tried running the installer with the following command:

jdk-8u25-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature"

This works fine on a machine with no JDK/JRE 8 installed. However, I am running into a few issues:

  • If JDK/JRE 8 is already installed, the installer UNINSTALLS both JDK & JRE instead of simply not doing anything (or re-installing)
  • If a reboot is required it is forcefully performed automatically, and I need to avoid that as there are other actions I need to perform in the script after the installation completes.
  • There is no VERBOSE mode / log file to indicate what the installer is actually doing

I have looked at these sources:

but they seem lacking and very confusing as to what will give me the wanted result.

Dagan Sandler
  • 475
  • 1
  • 5
  • 16
  • What is about deploy it as/in a folder and adjust the environment variables ? – PeterMmm Jan 20 '15 at 12:17
  • Is it safe to deploy Java that way on a Windows machine? Isn't the installer also setting different registry values that might be needed by some programs? – Dagan Sandler Jan 20 '15 at 12:46
  • Depends on your use case. Do you use the Java Browser Plug-in ? You shouldn't and if mandatory this probably won't work. You are running .jar with double-click ? Propably this solution won't work too. I'm not shure what will happen, if you make a version *agnostic* initial installation (specify C:\java as installation folder) and simple copy over new versions into that folder. – PeterMmm Jan 20 '15 at 13:08
  • Too many "ifs", I'd rather get the silent installer working properly. I really find it odd that it's so under-documented – Dagan Sandler Jan 20 '15 at 14:11

4 Answers4

10

I would tackle JDK and JRE separately:

The JDK does not depend on registry entries or whatever else the installer exe does. So install the JDK - without Public JRE - on just one machine using

jdk-8u25-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature"

Then you can simply zip up the resulting installation, copy and unzip it to other machines of the same OS type.

The JRE installer (separate download from Oracle) can be run with options and config file as documented here : http://docs.oracle.com/javase/8/docs/technotes/guides/install/windows_installer_options.html

Assuming the config is in the same directory as the installer exe, the option INSTALLCFG="%cd%\jre-install-options.cfg" can be used. Otherwise, a full path is required to the config file (INSTALLCFG="c:\path\to\jre-install-options.cfg"). So, something like this (with log file and assuming the config file is in the same directory of the exe):

jre-8-windows-i586.exe INSTALLCFG="%cd%\jre-install-options.cfg" /s /L C:\TMP\jre-install.log

It seems that the following jre-install-options.txt might work for you:

INSTALL_SILENT=Enable
REBOOT=Disable
STATIC=Enable

The config file options are listed here: http://docs.oracle.com/javase/8/docs/technotes/guides/install/config.html

The meaning of the last line is explained here : http://docs.oracle.com/javase/8/docs/technotes/guides/install/windows_installer_options.html#static_installation

JSuar
  • 21,056
  • 4
  • 39
  • 83
oldo
  • 2,092
  • 1
  • 15
  • 11
  • 1
    A relative path for INSTALLCFG did not work for me. See my [SuperUser](http://superuser.com/questions/970540/cannot-install-java-silently) question – Thomas Weller Sep 09 '15 at 14:58
  • What will the installer do if Java is already installed? Will it uninstall Java and reinstall it or will it only uninstall? And in the latter case will it indicate what it did, preferably not through the log? Will reboot be actually required before Java is usable? – Septagram Mar 22 '16 at 02:15
  • I know this is rather old post, but the config file has the [REMOVEOUTOFDATEJRES](https://docs.oracle.com/javase/8/docs/technotes/guides/install/config.html#table_config_file_options) flag that will remove old versions of the JRE. Setting this to zero might give you what you need. – DynaWeb Oct 03 '17 at 03:00
  • I know it's really old, but I need it now, do I need to copy the JDK also? – pgp1 Jun 22 '20 at 19:44
3

It seems there are constant changes to the supported commandline options. For the latest 8 Update 131, I had to abandon all msiexec style options because none of them worked. I used the documentation for the java version I downloaded to construct switches to the installer. As shown in answers above, the config file options can be passed to the installer on the commandline. The final command that I used in Packer to install Java on a Win2016 Server ami was:

Start-Process 'C:\Windows\Temp\jre-8u131-windows-x64.exe' `
  -ArgumentList 'INSTALL_SILENT=Enable REBOOT=Disable SPONSORS=Disable' `
  -Wait -PassThru

This command also adds Java to the system path by default, however not in the one it installs. Open a new powershell shell and it will be in the path for that shell (Inspect with $env.path)

Sources of truth:

http://docs.oracle.com/javase/8/docs/technotes/guides/install/windows_installer_options.html http://docs.oracle.com/javase/8/docs/technotes/guides/install/config.html#table_config_file_options

Todd Lyons
  • 998
  • 12
  • 19
1

I was facing similar issue with /s option. I i found a jdk bug https://bugs.openjdk.java.net/browse/JDK-8033364. I seems they have removed support for help or s. Try /qn it worked for me

jdk-8u92-windows-x64.exe /qn

Jitendra
  • 732
  • 1
  • 9
  • 29
  • I think `/s` just silences error messages. So, by removing `/s` you will actually see pop-ups when there's an error. – bvdb Jul 18 '18 at 10:24
  • this hasnt done it for me, i still get the UI up when executing the above with the /qn switches. – Royston Dec 04 '19 at 11:41
  • 1
    This works for me (Used in MDT) jre-8u231-win-x64.exe INSTALL_SILENT=1 AUTO_UPDATE=0 REBOOT=0 SPONSORS=0 REMOVEOUTOFDATEJRES=1 – Royston Dec 06 '19 at 10:28
0

For JRE silent installation :

start /wait msiexec /i "%~ java8.40x64.msi " JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No WEB_JAVA=1 /q

You can see full post here.

JSuar
  • 21,056
  • 4
  • 39
  • 83
Klodi
  • 1