1

I want to install Oracle JRE 1.8.202 x64 without making any changes to the current default java on target machines.

Detail on what I mean by 'Default Java'. I mean I don't want the installer to change of any of the settings that any current or old Java installer may have made to make itself the default (e.g. path changes, java executables dumped in windows or system32 directories, java.exe added or updated to C:\ProgramData\Oracle\Java\javapath\java.exe, environment variables like JAVA.HOME, Java executables added to registry apppaths).

The target machines are a mix of Windows machines that will have a huge variety of current Java installations. Some apps in the target environment rely on using the default java to run - I'd rather they didn't, but that's out of my control.

I can't see any options to stop the installer (jre-8u202-windows-x64.exe) setting it's JRE to the default. See the installer switches at Oracle JavaSE 8 Docs.

Anyone know of any methods other then just copying the files into a target directory?

Snapshotting the current default then restoring it is not an option - Oracle have changed 'setting the default' technique over time, so restoring cleanly would be a fragile rabbit hole.

David Gibson
  • 21
  • 1
  • 4
  • Don't. Install the JDK *without* installing the JRE that comes with the JDK. The JDK is not put on the PATH, but it *embeds* the full JRE. – Andreas Apr 30 '20 at 18:07
  • @Andreas, see the text above, it's a JRE I need, not a JDK. – David Gibson May 01 '20 at 09:58
  • But the JDK ***embeds*** a JRE, so you get the JRE without the installer messing with the PATH. – Andreas May 01 '20 at 15:36
  • Thanks. If the JDK does not update the java defaults, then this would work if disk space was not an unknown across my target estate. The JDK is likely to be too big for me to risk it without impact. – David Gibson May 05 '20 at 08:10

3 Answers3

0

For both JDK and JRE installations, Oracle differentiates between "patch in place" and "static" installations, where the former refers to updating an existing JRE with newer components in an existing directory, and the latter refers to performing a standalone install.

You want to run the install via command line:

jre-8u251-windows-i586.exe f:\jre_config_file

where jre-8u251-windows-i586.exe is the latest version of JRE 8 (of course you can specify whatever flavor of JRE 8 you're actually after), f:\jre_config_file is a file containing the line STATIC=1 and any other config options you're after.

You could also just feed the installer STATIC=1 as a command line arg.

The STATIC option is actually listed in the page you linked, so I'll spare you additional blather about config.

MarsAtomic
  • 10,436
  • 5
  • 35
  • 56
  • I'll try the `STATIC` option. I did see the option it in the Oracle doc, but didn't see anything about whether it will avoid setting/altering any existing default java settings (i.e. no changing the path, no dumping it's exe in `windows` or `system32` dirs, no updating the `java.exe` in `C:\ProgramData\Oracle\Java\javapath\java.exe`, no setting environment variables, no adding to registry apppaths). – David Gibson Apr 30 '20 at 20:07
  • @DavidGibson In the future, it would be helpful to include detailed requirements in the initial question, as opposed to adding them via comment, after the fact. – MarsAtomic Apr 30 '20 at 21:13
  • I've added that list of java installer 'set itself as the default' techniques into the main question. It's just a list of techniques I've come across, it may not be spot on. – David Gibson May 01 '20 at 10:11
  • 1
    I tried the `STATIC` option in combination with other low impact settings. Unfortunately, it did not work. It still added all the Java default executable environment, junction and registry entries detailed at [which-jre-does-c-programdata-oracle-java-javapath-java-exe-use](https://stackoverflow.com/questions/49540325/which-jre-does-c-programdata-oracle-java-javapath-java-exe-use). Full command line was `jre-8u251-windows-x64.exe AUTO_UPDATE=Disable INSTALLDIR="C:\Program Files\Java\jre1.8.0_251" INSTALL_SILENT=Enable NOSTARTMENU=Enable STATIC=Enable WEB_ANALYTICS=Disable WEB_JAVA=Disable` – David Gibson May 05 '20 at 08:20
0

I'm not sure if it's the best method but you could try using SDKMan to manage your Java versions on your target machine.

dope
  • 303
  • 4
  • 14
0

I did not find a managed way to use the installer without changing target system default java.

Instead, a custom installation process copies the installation tree into the target directory. Works fine.

David Gibson
  • 21
  • 1
  • 4