使用 CMD 脚本安装 Java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10805838/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install Java using CMD script
提问by Ilya
I am writing an application using Java and I want to send it to the customer. But he doesn't have Java on his computer (OS Win XP). I want to automate the installation using command shell scripting. Is it possible?
我正在使用 Java 编写一个应用程序,我想将它发送给客户。但是他的计算机上没有 Java(操作系统 Win XP)。我想使用命令 shell 脚本自动安装。是否可以?
回答by npe
There is a /s
option in JRE installer (see here), so basically you can.
However, you will have to somehow download JRE to client's workstation. I suggest using wgetfor this.
/s
JRE 安装程序中有一个选项(请参阅此处),因此基本上可以。但是,您必须以某种方式将 JRE 下载到客户端的工作站。我建议为此使用wget。
However, you can also use java-to-exe wrappers - JSmoothfor example can automagically download JRE for you if it is not installed.
但是,您也可以使用 java-to-exe 包装器 -例如,如果未安装 JRE,JSmooth可以自动为您下载 JRE。
回答by Juan Alberto López Cavallotti
You can make it on a bat file and ship a folder with an embeddable JVM, nevertheless I found using NSIS very effective for shipping swing APPS.
您可以将其制作在 bat 文件中,并提供一个带有可嵌入 JVM 的文件夹,不过我发现使用 NSIS 非常有效地发送 Swing 应用程序。
I'm not sure but I think you can also build the kind of installer you want.
我不确定,但我认为您也可以构建您想要的安装程序。
回答by Jis Ben
回答by Thomson256
Type "/?" parameter for the installation exe in console in the folder were installer relies.
类型 ”/?” 文件夹中控制台中安装 exe 的参数是安装程序所依赖的。
C:\TEMP>jdk-7u4-windows-x64.exe /?
C:\TEMP>jdk-7u4-windows-x64.exe /?
There you see shortly parameter reference. /passive & /quiet are probably what you need, create a install.cmd with something like
在那里你很快就会看到参数引用。/passive & /quiet 可能是你所需要的,创建一个 install.cmd 类似
cls
C:\TEMP>jdk-7u4-windows-x64.exe /quiet
echo installation complete
pause
回答by Octavio Ochoa
I used the following batch. I had a little trouble understanding the parameteres but finally this worked for me and without installing sponsor toolbars.
我使用了以下批次。我在理解参数时遇到了一些麻烦,但最终这对我有用并且没有安装赞助商工具栏。
"@echo off
copy "JavaSetup8u111.exe" "%USERPROFILE%\downloads\JavaSetup8u111.exe"
CD\
CD "%USERPROFILE%\downloads\"
start /B /WAIT JavaSetup8u111.exe /s SPONSORS=0