🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
3 messages
3 total messages Started by borland Thu, 29 Dec 2005 14:36
problem with Runtime.getRuntime().exec
#348
Author: borland
Date: Thu, 29 Dec 2005 14:36
30 lines
2078 bytes
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
-- 
Re: problem with Runtime.getRuntime().exec
#350
Author: Alexey N. Solofnenko
Date: Thu, 29 Dec 2005 17:01
47 lines
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/
Re: problem with Runtime.getRuntime().exec
#215
Author: Arthur Ore
Date: Sun, 01 Jan 2006 23:26
11 lines
1343 bytes
Running edit.com seems to be a little more awkward than most dos based
programs. Have a look at the final post to this thread

http://forum.java.sun.com/thread.jspa?forumID=45&threadID=538964

Ignore the fact that the person is trying to run it from a browser, just use 
the syntax shown.

Hope this helps

Arth
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads