Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: =?ISO-8859-1?Q?Sven_K=F6hler?= Newsgroups: comp.lang.java.programmer Subject: Re: exec problem is JDK 1.7.0_21 Date: Sat, 20 Apr 2013 19:07:38 +0300 Lines: 41 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: news.dfncis.de OAUd2jR+FE012lBkU7So5Q6KDVMmYZnzhhFeekKvugKNBS7RoVNtKwc38h Cancel-Lock: sha1:/438IkDUB/3wAI/066mxaNEwlKU= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130408 Thunderbird/17.0.5 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:23529 Am 20.04.2013 16:13, schrieb Joerg Meier: > Specifically, you use a path with a space in it. Frankly, I'm surprised > that ever worked. That being said, this seems to be a step back, not > forward. I have a question for everybody here: What would you expect new ProcessBuilder("c:\test.exe", "a b").start(); to do on Windows? Read the documentation of ProcessBuilder very careful. In particular this passage: > a command, a list of strings which signifies the external program > file to be invoked and its arguments, if any. Which string lists > represent a valid operating system command is system-dependent. For > example, it is common for each conceptual argument to be an element > in this list, but there are operating systems where programs are > expected to tokenize command line strings themselves - on such a > system a Java implementation might require commands to contain > exactly two elements http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html What is should do: 1) It should pass the command line parameter string "a b" to the program test.exe. Note: on Windows, command line parameters are a single string - there is no array as on UNIX. 2) What Java currently does: Since "a b" contains spaces, Java adds quotes to it. Hence, the parameter string that test.exe sees is "\"a b\"" which is wrong. 3) Workaround: use "\"a\" \"b\"" instead of "a b" because Java doesn't add quotes if the first and last character are quotes. The current implementation of ProcessBuilder for Windows is simply broken. Regards, Sven