| Author |
Executing System level commands
|
Naresh Rajan
Ranch Hand
Joined: Sep 08, 2005
Posts: 45
|
|
Hi I am trying to make an installable for my application. All i need to do is copy a set of folders into the folder of the users choice. For the front end i am using Swings. I will be getting the name of the folder (where the appln has to be copied) from the front end. I need to execute a set of commands that will be copying the folders from the CD to the specified location. This has to be done on both DOS and UNIX. How do i execute these system level commands from java???
|
Am not a pro and thats why am here!!!
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12928
|
|
|
You execute Windows command prompt or Unix commands by using java.lang.Runtime.exec() - see the API documentation.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Eric McIntyre
Greenhorn
Joined: Mar 03, 2005
Posts: 26
|
|
If you think at some point you might need to support more than those two platforms, you should copy them yourself using the java.io.File* classes (or java.nio.channels.FileChannel if you want to get fancy). Possibly slower, but insulates you from platform differences. Eric
|
 |
 |
|
|
subject: Executing System level commands
|
|
|