6 Replies Latest reply on Mar 12, 2009 6:06 PM by baftos

    executing external 16 bit programs

      i want to execute some old 16 bit programs as back-end . I used process object and successfully executed some 32 bit programs. But when executing 16 bit programs it gives error as 'error in setting up environment' on windows. why is it happening and what changes are needed?
      try     {
                     Process ps=Runtime.getRuntime().exec("cmd.exe /c star1.exe ");     
                     OutputStream stdin=null;
                     BufferedReader bos=new BufferedReader(new InputStreamReader(ps.getInputStream()));
                     String st=new String();
                     String ln=new String("");
                     catch (Exception e)
        • 1. Re: executing external 16 bit programs
          I am on XP, Java 1.6.0_11 and it works for me by using "cmd /C whatever16.exe".
          There may be some other reason, not the fact that it is 16 bit.
          Can you post the full error stack?
          • 2. Re: executing external 16 bit programs
            yeah i tried on some other 16 bit programs and it executes them, so it seems thats not the problem. the error i mentioned was being given to the command line without cmd.exe /c some.exe So thats not the case either. I found
            that it doesn't show output unless program is terminated. And if program is waiting for keyboard stroke it doesn't accept it through inputstream of java, which i have in my code. So problem for me now is how to get output form program while it is still running and how to give keyboard stroke input to program expecting such an input. i need a resource suggestion or any kind of help explaining these points. please help me out...
            • 3. Re: executing external 16 bit programs
              Did you read this [http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html] and you have no problems with 32 bit programs?
              • 4. Re: executing external 16 bit programs
                Thats a very good tutorial. Thanks for it. I will try some those things and post the result. No problem now is not 16 bit or 32 bit. Problem is to handle input of the program to be executed. i.e if it is is expecting a keyboard input i have to write that input in my output stream. i will try that and post result.
                • 5. Re: executing external 16 bit programs
                  Yes, it all worked well. It was some silly programming from me. Really thanks for that tutorial. I got my answers.
                  • 6. Re: executing external 16 bit programs
                    Good! Now, please take a look at the ProcessBuilder class, which is the new way of doing what Runtime does.
                    Many things from the article still apply, but ProcessBuilder relieves you from all the multithreaded mess: it allows you to
                    combine stdout and stderr into a single stream.