代码之家  ›  专栏  ›  技术社区  ›  deem

具有指定路径的Java JDK静默安装

  •  3
  • deem  · 技术社区  · 9 年前

    我想在指定版本中以静默模式(实际上,使用Chef)安装JDK。

    我的问题是,当我添加INSTALLDIR参数时,JavaJDK安装失败。如果没有它,JDK将安装在默认目录中( C: /程序文件/Java/ C: /程序文件(x86)/Java/ ).

    我正在运行命令

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

    也尝试过

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

    是什么让Java安装程序显示带有我可以在MSI安装程序中使用的参数的弹出窗口。

    C: /java语言/ 路径是现有目录。

    另外,我发现了这个网站: https://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html 在那里可以找到JDK的指定参数。

    我想在此安装中使用Chef资源窗口包

    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。

    是否有任何简单的方法来设置这些安装程序的安装路径 静音模式 ?


    规范:

    • 厨师12.4.1
    • Microsoft Windows 7
    • 我想安装的JDK版本: 6个35 , 7个79 8立方英尺 .

    谢谢你的帮助。

    1 回复  |  直到 9 年前
        1
  •  2
  •   deem    9 年前

    好的,我找到了解决这个问题的方法。

    而不是使用以下内容:

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

    我不得不使用这样的方法:

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

    这种方式确实有效 京东6 7. 。下面是一个完整的例子,供那些想知道如何做的人参考:

    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 installation fail

    对于 京东8 此参数运行良好:

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

    感谢您的所有努力!