具有指定路径的Java JDK静默安装 [英] Java JDK silent installation with specified path
问题描述
我想以静默模式(实际上是使用Chef)以指定版本安装JDK.
I want to install in silent mode (in fact, using Chef) JDK in specified version.
我的问题是,当我添加INSTALLDIR参数时,Java JDK安装失败.没有它,JDK将安装在默认目录( C:/Program Files/Java/或 C:/Program Files(x86)/Java/)中.
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/).
我正在运行命令
jdk-7u79-windows-i586.exe /s INSTALLDIR="C:/java"
也尝试过
jdk-7u79-windows-i586.exe /s INSTALLDIR:"C:/java"
是什么使Java安装显示带有我可以在MSI安装程序中使用的参数的弹出窗口.
what makes Java installation show pop-up window with parameters I can use in MSI installer.
C:/java/路径是现有目录.
此外,我找到了这个网站: https://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html 您可以在其中找到JDK的指定参数.
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.
我要使用Chef资源的Windows软件包进行安装
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
什么使输出
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
我应该添加我不想安装JRE -我的目标是安装JDK.
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?
规格:
- 厨师12.4.1
- Microsoft Windows 7
- 我要安装的JDK版本: 6u35 , 7u79 和 8u45 .
- Chef 12.4.1
- Microsoft Windows 7
- Versions of JDK I would like to install: 6u35, 7u79 and 8u45.
感谢您的帮助.
推荐答案
好,我找到了解决此问题的方法.
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('/','\\')}\\\"\""
这种方式可以确保 JDK 6 和 7 .对于那些想知道如何做的人来说,这是一个完整的例子:
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有问题-使用此行会使JDK的安装损坏:
JDK 8 has problem though - using this line makes installation of JDK corrupt:
对于 JDK 8 ,此参数效果很好:
For JDK 8 worked fine this parameter:
options "/s INSTALLDIR=\"#{node['path']['JDK1.8'].gsub('/','\\')}\""
感谢您的所有努力!
这篇关于具有指定路径的Java JDK静默安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!