Explicit Java JDK installation with specified path
I want to silently install (actually using Chef) the JDK in the specified version.
My problem is when I add the INSTALLDIR parameter the Java JDK installation fails. Without it, the JDK will be installed in the default directory (C: / Program Files / Java / or C: / Program Files (x86) / Java /).
I run the command
jdk-7u79-windows-i586.exe /s INSTALLDIR="C:/java"
and also tried
jdk-7u79-windows-i586.exe /s INSTALLDIR:"C:/java"
which makes the Java install popup, with options that I can use in the MSI installer.
C: / java / path - existing directory.
Additionally, I found this site: https://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html where you can find specific options for the 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 concludes
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 must add that I do not want to install the JRE . My goal is to install the JDK.
Is there an easy way to set the install path for these installers in silent mode?
Specification:
- Chef 12.4.1
- Microsoft Windows 7
- JDK versions I would like to install: 6u35 , 7u79 and 8u45 .
Any help would be appreciated, thanks.
source to share
Ok I found a solution to 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 exactly for JDK 6 and 7 . Here's a complete example for anyone wondering 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 a problem though - using this line makes the JDK installation corrupt:
For JDK 8 this setting worked fine:
options "/s INSTALLDIR=\"#{node['path']['JDK1.8'].gsub('/','\\')}\""
Thanks for all your efforts!
source to share