S
S
Sapun4ik2015-06-11 18:26:53
Java
Sapun4ik, 2015-06-11 18:26:53

Get a response from a closed program (C#/Java)?

Good time of the day.
1) From the java code, you need to start the console application by passing a string to it (the xml address that contains the settings).
2) After the program finishes its work and closes (the console application acts as an xml -> word doc converter), you need to receive a response about the processing status. Whether everything is successful or what jambs.
1) the first thing I did:

public class MyClass {
  public static void main (String[] args) throws Exception {
     Runtime.getRuntime (). exec("cmd.exe /c start D:\\program1.exe 55");
    }
}

2) I take the line in the console, everything is fine:
namespace program1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                if (args.Length != 0)
                {
                    foreach (string s in args)
                    {
                        Console.WriteLine(s);
                    }
                }
                else
                {
                    Console.WriteLine("Возникла ошибочка!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

Response (0) - started successfully, (1) - an error occurred I also received. But you need to track the error more informatively. And the main answer is to close the program. And now the questions:
How to get the completion result? How to send after closing the console (Closes automatically as it creates and fills a word document)? And how to get in java?
Also, if I'm not calling correctly or mb accepting data, correct plz =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2015-06-11
@Sapun4ik

stackoverflow.com/questions/8149828/read-the-outpu...
www.javaworld.com/article/2071275/core-java/when-r...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question