12 Replies Latest reply on Oct 4, 2004 6:45 PM by 807541

    Runtime.exec error in windows

    807541
      When i try to run an external program with Runtime.exec() in windows 2000, i get a windows pop-up with the following error msg:

      d:\winnt\system32\ntvdm.exe
      Error while setting up environment for the application.


      I have no idea how to fix this since i have no clue to what that error means.

      Thanks
      Rumy
        • 1. Re: Runtime.exec error in windows
          807541
          To correct this problem, perform one or more of the following:

          * Run the emergency repair disk (ERD) to replace the missing or corrupt file(s). The ERD also verifies the integrity of Windows NT system files in general.

          * Manually expand the Autoexec.nt, Config.nt, and Command.com files off the Windows 2000 CD-ROM.

          * Move the paging file to a permanent physical drive.

          To resolve this problem, obtain the latest service pack for Windows 2000 or Windows 2000 Server, Terminal Server Edition.
          • 2. Re: Runtime.exec error in windows
            807541
            I've personally just encountered the same error. I am building a piece of demonstration software to distribute with my graduate school applications to demonstrate my programming experience and I wish to include a set of programs I wrote some years ago in Pascal and C++. The software has been compiled for MS-DOS 6.0. I am using the following command to execute the software from within my Java program:
            Runtime.getRuntime().exec(new String[]{"command.com","/c","12cards.bat"});
            The batch file performs the appropriate setup operations for the program and runs the executable. When I run this code segment, I receive the following error:

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

            I have another code segment in which I attempt to run the executable myself (without the help of command.com or the batch file). The code segment is as follows:
            Runtime.getRuntime().exec(new String[]{"12cards.exe"}, new String[0], workingDir);
            When I run this code segment, the following IOException is thrown:
            java.io.IOException: CreateProcess: 12CARDS.EXE error=2
                 at java.lang.Win32Process.create(Native Method)
                 at java.lang.Win32Process.<init>(Win32Process.java:66)
                 at java.lang.Runtime.execInternal(Native Method)
                 at java.lang.Runtime.exec(Runtime.java:566)
                 at (my code)
            I have already found the document on Microsoft's support website which describes a solution to this problem. Manually extracting the autoexec.nt, config.nt, and command.com files from the installation CD-ROM did not help.

            The most confusing element of this: 12CARDS.EXE runs fine if I execute it from Windows Explorer. It's only a problem if it's executed from within my Java program. I have two other DOS programs which I want to include as well; I am having the same trouble with them.

            Any advice will be much appreciated. Thanks!
            • 3. Re: Runtime.exec error in windows
              807541
              Try this:
              Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "12cards.exe"}, null, workingDir);
              • 4. Re: Runtime.exec error in windows
                807541
                Thanks for the help. :) Unfortunately, that doesn't seem to work either. I run the code segment you described and an instance of CMD.EXE starts up. That spawns an instance of NTVDM.EXE. Then, they sit there quietly... no CPU time is being consumed, no extra memory is being requested. It seems possible that the 12CARDS program may have started; I cannot, however, see anything of it on my screen. I can terminate those two processes without problem.

                I have tested this software on a Windows 2000 SP4 installation and a Windows XP SP1 installation. In both cases, I have the exact same problem. Both machines are running the J2SDK v1.4.2_03.

                Anyone have any more suggestions? Thanks again for your help.
                • 5. Re: Runtime.exec error in windows
                  807541
                  Update!

                  The following code segment seems to do the job:
                  Runtime.getRuntime().exec(new String[]{"cmd.exe","/c", "start","/wait","/i","12cards.bat"});
                  I had to add an "exit" command to the end of 12cards.bat to make the newly-created command window go away, but it functions for WinNT-kernel systems.

                  I have a question, though: how far back does the "start" command go? Is it available on Win9x systems? What about in MS-DOS? I don't currently have a machine installed with these systems; if anyone knows, I'd appreciate the info.

                  Thanks again for your help.
                  • 6. Re: Runtime.exec error in windows
                    jschellSomeoneStoleMyAlias
                    start is not available on win95.
                    I am unsure about win98, but I kind of suspect not.
                    • 7. Re: Runtime.exec error in windows
                      807541
                      Alright, thanks. :)
                      • 8. Re: Runtime.exec error in windows
                        DrClap
                        start is not available on win95.
                        I am unsure about win98, but I kind of suspect not.
                        I'm not sure whether that's true. I do know however that cmd.exe doesn't work on Windows 95/98/ME, the name of the command processor there is command.com instead.
                        • 9. Re: Runtime.exec error in windows
                          jschellSomeoneStoleMyAlias
                          start is not available on win95.
                          I am unsure about win98, but I kind of suspect not.
                          I'm not sure whether that's true.
                          I just tested it.

                          I was wrong. It is available on 95.
                          • 11. Re: Runtime.exec error in windows
                            807541
                            I have the same problem but using jakarta ant. I tried to call cvs task and it fails on Win2K3 server but works on XP machines.
                            • 12. Re: Runtime.exec error in windows
                              807541
                              Ok, the problem was with Ant 1.5.1. When I tried Ant 1.6.2 everything goes well.