3

I want to install in silent mode (in fact, using Chef) JDK in specified version.

My problem is, when I add INSTALLDIR parameter, Java JDK installation fails. Without it JDK will install in default directory (C:/Program Files/Java/ or C:/Program Files (x86)/Java/).

I am running command

jdk-7u79-windows-i586.exe /s INSTALLDIR="C:/java"

and also tried

jdk-7u79-windows-i586.exe /s INSTALLDIR:"C:/java"

what makes Java installation show pop-up window with parameters I can use in MSI installer.

C:/java/ path is existing directory.

Additionaly, I found this site: https://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html where you can find specified parameters for JDK.

I want to use Chef resource windows-package for this installation

windows_package node['name']['JDK1.8'] do
    source                  node['source']['JDK1.8']
    installer_type          :custom
    action                  :install
    options                 '/s INSTALLDIR=C:/java2'
end

What makes output

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0, 42, 127], but received '1603'
---- Begin output of start "" /wait "D:\install\jdk-7u79-windows-i586.exe" /s INSTALLDIR=C:/java & exit %%ERRORLEVEL%% ----
STDOUT: 
STDERR: 
---- End output of start "" /wait "D:\install\jdk-7u79-windows-i586.exe" /s INSTALLDIR=C:/java & exit %%ERRORLEVEL%% ----
Ran start "" /wait "D:\install\jdk-7u79-windows-i586.exe" /s INSTALLDIR=C:/java & exit %%ERRORLEVEL%% returned 1603

I should add I don't want to install JRE - my goal is to install JDK.

Is there any simple way to set up installation path for these installers in silent mode?


Specification:

  • Chef 12.4.1
  • Microsoft Windows 7
  • Versions of JDK I would like to install: 6u35, 7u79 and 8u45.

I will appreciate any help, thanks.

deem
  • 1,252
  • 1
  • 19
  • 38
  • 3
    Have you tried using `C:\Java` instead of `C:/Java` ? Forward slashes aren't strictly legal in Windows paths, and sometimes they don't work. – Harry Johnston Jul 31 '15 at 22:04
  • 1
    Have you considered using the community cookbook? It reportedly supports windows: https://supermarket.chef.io/cookbooks/java – Mark O'Connor Aug 01 '15 at 08:18
  • @Harry Johnston, yes, I have tried both ways of slashes in path, no success though. – deem Aug 02 '15 at 19:19
  • @Mark O'Connor, I will look into your solution tomorrow, many thanks. – deem Aug 02 '15 at 19:20

1 Answers1

2

Ok, I found solution for this problem.

Instead of using something like:

options     "/s INSTALLDIR=#{node['path']['jdk']}"

I had to use something like this:

options     "/v\"/qn INSTALLDIR=\\\"#{node['path']['JDK1.7'].gsub('/','\\')}\\\"\""

This way works for sure JDK 6 and 7. Here is full example for those who wonder, how to do it:

windows_package node['name']['JDK1.7']  do
    source                  node['source']['JDK1.7']
    action                  :install
    installer_type          :custom
    options                 "/v\"/qn INSTALLDIR=\\\"#{node['path']['JDK1.7'].gsub('/','\\')}\\\"\""
end

JDK 8 has problem though - using this line makes installation of JDK corrupt:

JDK installation fail

For JDK 8 worked fine this parameter:

options     "/s INSTALLDIR=\"#{node['path']['JDK1.8'].gsub('/','\\')}\""

Thanks for all your efforts!

deem
  • 1,252
  • 1
  • 19
  • 38