Name: dbT83986 Date: 02/15/99
I want to launch a DOS program from Java using
Runtime.exec(). This DOS program does I/O using
stdin/stdout. I am using the followng program:
public class SimpleTest
public static void main( String args )
boolean winNT = System.getProperty( "os.name" ).startsWith( "Windows NT" );
Runtime.getRuntime().exec( ( winNT ? "cmd.exe" : "command.com" ) +
" /c start /wait C:\\prog.exe" ).waitFor();
catch ( Exception e )
Under Windows NT, this works fine and pops up a
DOS console window, with the stdin/stdout streams
Under Windows 95, a console pops up but does not
display stdout; neither will it accept any input.
If "C:\\prog.exe" is replaced by "echo hello" then
no console is produced at all under Win95; NT
produces a normal console with "hello" at the top.
I have tried various methods of getting Win95 to
produce a console that accepts I/O. These include
writing a batch file to run prog.exe in a console
and writing a batch file to run a batch file in a
console that runs prog.exe in a console! But to
no avail; it seems Win95 cannot be persuaded to
launch a DOS console with I/O via the
CreateProcess call in Java Runtime.
Microsoft documents a difference in DOS Console
stream handling between 95 and NT:
I suspect that the native code in Java that
implements Runtime.exec() with Windows system
calls needs some workarounds to work better with
Any solutions would be greatly appreciated!
(Review ID: 30676)