Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing JDK 8 and JRE 8 silently on a Windows machine through command line

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:

  • JDK Installation for Microsoft Windows - Installing the JDK Silently
  • Windows JRE Installer Options - Command-Line Installation

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

like image 532
Dagan Sandler Avatar asked Jan 20 '15 10:01

Dagan Sandler


People also ask

How do I download JDK from command prompt?

POSSIBLE SOLUTIONS: 1) Start a CMD shell (click "Start" button ⇒ "run..." ⇒ enter "cmd") and issue a path command: prompt> path PATH=....... 2) Check if it includes your JDK's "bin" directory. For example, suppose that your JDK is installed in "c:\program files\java\jdk-15.0.

Can I install both JDK and JRE?

1 Overview of JDK 10 and JRE 10 Installation The type of installation depends on your requirement and the platform that you choose to install. Download and install the Java Development Kit (JDK) for your platform. The JDK includes the JRE, so you do not have to download both separately.


1 Answers

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

like image 163
oldo Avatar answered Oct 20 '22 00:10

oldo