Runtime.getRuntime().exec causing Windows 16-bit error!  
Author Message
paul brown





PostPosted: 2004-1-27 12:04:00 Top

java-programmer, Runtime.getRuntime().exec causing Windows 16-bit error! Hi there,

I'm trying to do something i've done many times before without problem, even
from signed applets...
trying to run a system command from Java.

I'm doing this:

import java.io.*;
public class SysCommand{
public static void main(Stirng[] args){
try{
Process proc =
Runtime.getRuntime().exec(
new String[]{"command.com",
"/C",
"echo",
"%windir%"});
BufferedReader reader =
new BufferedReader(
new InputStreamReader(
proc.getInputStream()));
System.out.println(reader.readLine());
proc.waitFor();
proc.destroy();
}
catch(Throwable th){
th.printStackTrace();
}
}
}

I'm trying to find out where the Windows directory is (i need to copy some
DLL's into there as part of an installation process).

When i run this, Windows raises a dialog box saying:

_______________________________________________________________
|16 bit MS-DOS Subsystem
|
|
|
| C:\WINNT\system32\ntvdm.exe
|
| Error while setting up environment for the application. Click 'Close'
to terminate |
---------------------------------------------------------------------------
---------

I'm running JDK 1.4.2_02 on a Win2K box.

Any ideas?

Thanks,
Paul



 
paul brown





PostPosted: 2004-1-27 12:16:00 Top

java-programmer >> Runtime.getRuntime().exec causing Windows 16-bit error! that's ok..

it should have been

Process proc =
Runtime.getRuntime().exec(
new String[]{"cmd",
"/C",
"echo",
"%windir%"});
BufferedReader reader =

it works now ...

thanks
Paul




"paul brown" <email***@***.com> wrote in message
news:4015e316$email***@***.com...
> Hi there,
>
> I'm trying to do something i've done many times before without problem,
even
> from signed applets...
> trying to run a system command from Java.
>
> I'm doing this:
>
> import java.io.*;
> public class SysCommand{
> public static void main(Stirng[] args){
> try{
> Process proc =
> Runtime.getRuntime().exec(
> new String[]{"command.com",
> "/C",
> "echo",
> "%windir%"});
> BufferedReader reader =
> new BufferedReader(
> new InputStreamReader(
> proc.getInputStream()));
> System.out.println(reader.readLine());
> proc.waitFor();
> proc.destroy();
> }
> catch(Throwable th){
> th.printStackTrace();
> }
> }
> }
>
> I'm trying to find out where the Windows directory is (i need to copy some
> DLL's into there as part of an installation process).
>
> When i run this, Windows raises a dialog box saying:
>
> _______________________________________________________________
> |16 bit MS-DOS Subsystem
> |
> |
> |
> | C:\WINNT\system32\ntvdm.exe
> |
> | Error while setting up environment for the application. Click
'Close'
> to terminate |
> -------------------------------------------------------------------------

 
Chris Smith





PostPosted: 2004-1-27 12:21:00 Top

java-programmer >> Runtime.getRuntime().exec causing Windows 16-bit error! paul brown wrote:
> I'm trying to do something i've done many times before without problem, even
> from signed applets...
> trying to run a system command from Java.

Okay... see below.

> Process proc =
> Runtime.getRuntime().exec(
> new String[]{"command.com",
> "/C",
> "echo",
> "%windir%"});

> When i run this, Windows raises a dialog box saying:
>
> _______________________________________________________________
> |16 bit MS-DOS Subsystem
> |
> |
> |
> | C:\WINNT\system32\ntvdm.exe

You're running this on Windows NT (or a derivative, such as Windows 2000
or XP). The Windows NT command interpreter is called cmd.exe, not
command.com. The command.com interpreter is present, but belongs to
that class of outdated and decaying code that can't be expected to run
reliably.

I don't know exactly what's wrong, but using cmd.exe on Windows NT-based
platforms will almost certainly fix the problem.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation