java打包软件静默安装,具有指定路径的Java JDK静默安装

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.

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.

解决方案

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:

rN74a.png

For JDK 8 worked fine this parameter:

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

Thanks for all your efforts!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值