jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Executing System level commands Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Executing System level commands" Watch "Executing System level commands" New topic

Executing System level commands

Naresh Rajan
Ranch Hand

Joined: Sep 08, 2005
Posts: 45

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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15045

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 8 API documentation
Eric McIntyre

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.

I agree. Here's the link: http://aspose.com/file-tools
subject: Executing System level commands
It's not a secret anymore!