execute commands of another program from a tidesdk

2019-06-08 10:44发布

I'm testing tidesdk.

I have a java program that reads from standard input. I run the program through the console console

java -cp MyProgram.jar package.MyMainClass

And then execute commands and get results.

there any way to do with tidesdk?

Edit: The problem was that calls the java program with a list of one element (which contained the command separated by spaces) It solved with passing every word to a item of list (and removing the spaces). Right now I have porblemas to write standard input. This is what I'm trying.

 var input = Ti.Process.createPipe();

 var process = Ti.Process.createProcess({
                   args:['java', '-cp', 'C:/.../MyProgram.jar', 'package.MyMainClass'],
                   stdin: input
                });

    //process.setOnReadLine(function(line) { alert(line) });
    process.launch();

    input.write("comand parameter1 parameter2\n"); //This line does not work

The java program starts. But never gets a command.

1条回答
2楼-- · 2019-06-08 11:12

Checkout Documentation of Ti.Process.createProcess. That is exactly what you are looking for:

http://tidesdk.multipart.net/docs/user-dev/generated/#!/api/Ti.Process

查看更多
登录 后发表回答