File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes execute external program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "execute external program" Watch "execute external program" New topic
Author

execute external program

kanika dua
Greenhorn

Joined: Apr 17, 2002
Posts: 5
I am trying to execute an external program-
net2phone(Its a freeware to make PC to Phone calls) from a java program.
public class TestExec {
public static void main(String[] args) throws Exception {
Process p = Runtime.getRuntime().exec(
"\"C:/Program Files/Net2Phone CommCenter/CommCtr.exe\"");
p.waitFor();
}
}
I want to use something similar to sendKeys in VB to send the number to be dialed automatically via the script. Can somebody help me with this or if any other command is available in java to accomplish this-
Thanks
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
kaniks
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!


Dave
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
First, you are using exec() incorrectly. It does not parse a command line with spaces and quotes the way you are expecting it to. It thinks all quotes are literals and tokenizes only on spaces. You will want to tell it that your command is pre-parsed by using it like this:

I also don't know of any sendkeys function in Java. See if the program accepts command line arguments, as that would be the standard way of passing data to it. For example, something like:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: execute external program
 
Similar Threads
executing other programs
How to access HD info like, size, free space..?
run an no java prog. from java
Executing External Command with a Twist
Executing an external application