File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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: 15096

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* 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:
subject: Executing System level commands
jQuery in Action, 3rd edition