starter = launcher.launch().cmds(jdkBundle, "-noregister");
}
int exit = starter
.stdin(new ByteArrayInputStream("yes".getBytes())).stdout(out)
.pwd(new FilePath(launcher.getChannel(), expectedLocation)).join();
if (exit != 0)
throw new AbortException(Messages.JDKInstaller_FailedToInstallJDK(exit));
// JDK creates its own sub-directory, so pull them up
List<String> paths = fs.listSubDirectories(expectedLocation);
for (Iterator<String> itr = paths.iterator(); itr.hasNext();) {
String s = itr.next();
if (!s.matches("j(2s)?dk.*"))
itr.remove();
}
if(paths.size()!=1)
throw new AbortException("Failed to find the extracted JDKs: "+paths);
// remove the intermediate directory
fs.pullUp(expectedLocation+'/'+paths.get(0),expectedLocation);
break;
case WINDOWS:
/*
Windows silent installation is full of bad know-how.
On Windows, command line argument to a process at the OS level is a single string,
not a string array like POSIX. When we pass arguments as string array, JRE eventually
turn it into a single string with adding quotes to "the right place". Unfortunately,
with the strange argument layout of InstallShield (like /v/qn" INSTALLDIR=foobar"),
it appears that the escaping done by JRE gets in the way, and prevents the installation.
Presumably because of this, my attempt to use /q/vn" INSTALLDIR=foo" didn't work with JDK5.
I tried to locate exactly how InstallShield parses the arguments (and why it uses
awkward option like /qn, but couldn't find any. Instead, experiments revealed that
"/q/vn ARG ARG ARG" works just as well. This is presumably due to the Visual C++ runtime library
(which does single string -> string array conversion to invoke the main method in most Win32 process),
and this consistently worked on JDK5 and JDK4.
Some of the official documentations are available at
- http://java.sun.com/j2se/1.5.0/sdksilent.html
- http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/silent.html
*/
String logFile = jdkBundle+".install.log";
ArgumentListBuilder args = new ArgumentListBuilder();
args.add(jdkBundle);
if (isJava15() || isJava14()) {
args.add("/s","/v/qn REBOOT=ReallySuppress INSTALLDIR=\\\""+ expectedLocation +"\\\" /L \\\""+logFile+"\\\"");
} else {
// modern version supports arguments in more sane format.
args.add("/s","/v","/qn","/L","\\\""+logFile+"\\\"","REBOOT=ReallySuppress","INSTALLDIR=\\\""+ expectedLocation+"\\\"");
}
// according to http://community.acresso.com/showthread.php?t=83301, \" is the trick to quote values with whitespaces.
// Oh Windows, oh windows, why do you have to be so difficult?
int r = launcher.launch().cmds(args).stdout(out)
.pwd(new FilePath(launcher.getChannel(), expectedLocation)).join();
if (r != 0) {
out.println(Messages.JDKInstaller_FailedToInstallJDK(r));
// log file is in UTF-16
InputStreamReader in = new InputStreamReader(fs.read(logFile), "UTF-16");
try {