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

删除回忆录丶 提交于 2019-12-04 01:22:38
odoepner

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

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

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

Klodi

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!