File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes runtime exec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "runtime exec" Watch "runtime exec" New topic

runtime exec

Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
Is it possible to run a command line type instruction from within Java, even if the command line isn't a program like word.exe ( I am trying to run a mysqldump command to copy a database from one linux box to another ).
...Is it possible to call a shell script using runtime exec? or is there a better way
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
Shell scripts are interpretted by a program such as bash. You could call bash with an argument of the shell script.
Thomas Smets
Ranch Hand

Joined: Dec 11, 2001
Posts: 111
Peter it depends what you need to do !
For a pure dump, just do as said :
exec(new String(){"/bin/bash", "/home/me/"})
this will be the fastest.
Otherwise you may have a JDBC connection from DB to DB, also !

Thomas Smets
Just another developper
I agree. Here's the link:
subject: runtime exec
It's not a secret anymore!