• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

execute external program

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
reply
    Bookmark Topic Watch Topic
  • New Topic