I am trying to run a program by command in a Java class. This program has a specific commands which I would like to execute in a Java program. Running this program in the command line would be as follow:
I'm assuming you have a program named "xx" that you can manually run from a command line. I also assume from your description that draw(1,2) is supposed to be handled within the xx program. If this is the case you'll have to pass "draw(1,2)" as an argument to the "xx" program and make sure that xx knows how to handle an argument of draw(1,2). You should be able to test xx from the command line buy running something like:
P.S. the quotes around the arguments may be necessary in order to avoid having the command-line interpreter from doing something funny with any special characters.
When I was your age I was toggling in the bootstrap code on the front panel
Have you tried writing the commands (including line breaks) to the Process' output stream as returned by getOutputStream()? Don't forget to flush after sending a command, or it may not work immediately.
It looks like xx is a program, and draw(1,2) is a command inside of program xx.
The Java program is to telling the operating system to run the command "xx" and then run the command "draw(1,2)".
What you should try is to see if program xx can be ran using a redirect of the input. You need to look up the redirect for your operating system, but "<<" may work. Put the command "draw(1,2)", and other commands, into a file, "commands.txt", with one command on each line. Then try the command "xx << commands.txt". If this works, then your program needs to write the "commands.txt" file, and then execute program xx with the redirect.