Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: runtime.exec problems Date: Sat, 25 Jun 2011 16:09:59 -0400 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 25 Jun 2011 20:11:02 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="BrOwaJANne849xlH+KPYjQ"; logging-data="29672"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+X67S7AfaERZ2oEe8+Y6oi" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 In-Reply-To: Cancel-Lock: sha1:6DXFeb+PH2Sx9Ike0Lfh1MuwNQw= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5669 On 6/25/2011 1:58 PM, Memo wrote: > I can't get runtime.exec to execute a program in Java. I am trying to > execute a bat file. I read that in order to run bat files as opposed > to .exe files the runtime command has to include "cmd /c start" before > the name of the bat file. I have run bat files successfully this way > before. > > The command that I am running works when typed from the command line. > It is: > > z:/n4/pkg/MrServers/MrVista/Simu/StartSimEnv.bat -AutoStart > GOLD_256x512.dat > > When I try the following code: > > File file = new File(imageDir); > cmd = "C:\WINDOWS\system32\cmd /c start "+simDir+"StartSimEnv.bat - > AutoStart " + imageName; I assume `cmd' is a String, and `simDir' and `imageName' are things that have reasonable toString() methods. Even so, I cannot imagine how this would get through a Java compiler, since the only context I can think of that would make it valid would be to surround it with /* */. Here's a thought: Show us the actual code, not a half-baked uncompilable paraphrase. I could make a bunch of guesses about what your code actually is, and then I could try to debug the code I'd guessed at -- but the thing you want debugged is your code, not my guesswork. -- Eric Sosman esosman@ieee-dot-org.invalid