Article View: borland.public.jbuilder.java.language
Article #350Re: problem with Runtime.getRuntime().exec
From: Alexey N. Solofnenko
Date: Thu, 29 Dec 2005 17:01
Date: Thu, 29 Dec 2005 17:01
47 lines
2849 bytes
2849 bytes
On any system you need to pump (read and discard read data) STDOUT and
STDERR in separate threads from the child process. Otherwise the process
will be blocked on one of its outputs when output buffer is flushed.
Some web sites recommend closing the streams (including STDIN) right a
way, but there are also reports that it does not always work. See Google
for more information.
- Alexey.
Ps. Please also use exec(String[]) version (or even better - exec(args,
null, executionDirectory) ), because it will work correctly even if you
have spaces in paths or arguments.
borland wrote:
> Hello,
> I' ve a problem. I have windows XP professional and working JBuilder X.
> In my application (swing) when i have windows program:
> .........................................................................................................
> try {
> Runtime.getRuntime().exec("C:\\WINDOWS\\system32\\cmd.exe /C
> WINPROG"); // WINPROG - windows program (excel)
> }
> catch (Exception ex){
> ex.printStackTrace();
> }
> .........................................................................................................
> I have no problem.
> But when i have os program:
> .........................................................................................................
> try {
> Runtime.getRuntime().exec("C:\\WINDOWS\\system32\\cmd.exe /C
> DOSPROG"); // DOSPROG - dos program (c:\windows\system32\edit.com)
> }
> catch (Exception ex){
> ex.printStackTrace();
> }
> .........................................................................................................
> Nothing happens (not open dos window)
> What can it be?
>
> Thanks in advance.
> Apostolis
> Hatziyannis
--
Alexey N. Solofnenko
home: http://trelony.cjb.net/
Technical Details
Message-ID:
<43b415a1$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<43b3f43e$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,f3438594c1f41e9b X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 29 Dec 2005 09:01:32 -0800 From: "Alexey N. Solofnenko" <nospam@nospam.comp> User-Agent: Thunderbird 1.5 (X11/20051228) MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Re: problem with Runtime.getRuntime().exec References: <43b3f43e$1@newsgroups.borland.com> In-Reply-To: <43b3f43e$1@newsgroups.borland.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.4.135.226 Message-ID: <43b415a1$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1135875489 24.4.135.226 (29 Dec 2005 08:58:09 -0700) Lines: 47 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail