Results 1 to 3 of 3
Thread: Run commands in a Java class
- 05-29-2011, 03:47 AM #1
Member
- Join Date
- May 2011
- Posts
- 1
- Rep Power
- 0
Run commands in a Java class
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:
[user@mycomputer ~] xx
xx> draw(1,2)
....
...
...
xx>end()
[user@mycomputer ~]
I tried to do the following:
but it gave me the following error:Java Code:Process child = Runtime.getRuntime().exec("xx"); int returnCode = child.waitFor(); System.out.println("Return code = " + returnCode); child = Runtime.getRuntime().exec("draw(1,2)"); returnCode = child.waitFor(); System.out.println("Return code = " + returnCode);
java.io.IOException: Cannot run program "draw(1,2)": java.io.IOException: error=2, No such file or directory
It seems that what this code did is equivalent to the following in the command line:
[user@mycomputer ~] xx
[user@mycomputer ~] draw(1,2)
It is supposed that draw(1,2) is executed under the program xx.
Any help would be appreciated.
-
No idea if this would work, but what if you tried to pass the other commands through the process's output stream obtained via the Process method, getOutputStream(). If you haven't done so, be sure that you read this article: When Runtime Exec Won't
- 05-29-2011, 05:00 AM #3
Similar Threads
-
Commands on java.
By Slithice in forum New To JavaReplies: 15Last Post: 11-15-2012, 10:06 AM -
using RMAN commands in Java
By mario_tim in forum JDBCReplies: 4Last Post: 03-22-2011, 04:59 AM -
At commands in java
By strictlydivine.elite in forum Advanced JavaReplies: 1Last Post: 11-22-2010, 09:55 AM -
Run Unix commands from Java
By yahyaaa in forum New To JavaReplies: 13Last Post: 06-17-2010, 11:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks