Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37650

Re: a crazy java problem

Path csiph.com!aioe.org!.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: a crazy java problem
Date Fri, 10 Nov 2017 22:53:22 -0500
Organization Aioe.org NNTP Server
Lines 37
Message-ID <ou5s7h$97m$1@gioia.aioe.org> (permalink)
References <33ab661b-810a-4d40-86ef-907752ec35aa@googlegroups.com> <37cbaf57-b52e-4f12-93c1-e3da6b01c9d9@googlegroups.com>
NNTP-Posting-Host PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0
Content-Language en-US
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.java.programmer:37650

Show key headers only | View raw


On 11/10/2017 9:43 PM, mcheung63@gmail.com wrote:
> mche...@gmail.com於 2017年11月11日星期六 UTC+8上午10時41分45秒寫道:
>>     this code can run successfull in a simple java main():

>> 			String str = CommonLib.runCommand("C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe -Tpng C:\\Users\\Peter\\AppData\\Local\\Temp\\1.asm6434829820851445658.dot -o C:\\Users\\Peter\\desktop\\1.asm3568795673124410656.png");

>> But if running inside the netbeans plugin module, it throws an exception:
>>
>> java.io.IOException: CreateProcess error=2, The system cannot find the file specified

>> Caused: java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified

>> Any hints?

> 	public static String runCommand(String command, int skipLine) throws Exception {

> 		Process p = Runtime.getRuntime().exec(command);

I am more puzzled over why it sometimes work.

As I read the JavaDoc for Runtime.exec overloads then command line
get parsed to parts simply by splitting at spaces. That does not
find the correct command.

So I will suggest:

String str = CommonLib.runCommand(new String[] { "C:\\Program Files 
(x86)\\Graphviz2.38\\bin\\dot.exe", "-Tpng", 
"C:\\Users\\Peter\\AppData\\Local\\Temp\\1.asm6434829820851445658.dot", 
"-o", "C:\\Users\\Peter\\desktop\\1.asm3568795673124410656.png" });

public static String runCommand(String[] cmdarr, int skipLine) throws 
Exception {

Process p = Runtime.getRuntime().exec(cmdarr);

Arne

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

a crazy java problem mcheung63@gmail.com - 2017-11-10 18:41 -0800
  Re: a crazy java problem mcheung63@gmail.com - 2017-11-10 18:43 -0800
    Re: a crazy java problem Arne Vajhøj <arne@vajhoej.dk> - 2017-11-10 22:53 -0500

csiph-web