Two Laptop Bag*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 14074

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

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
Similar Threads
neep help - files inside folder structure
Creating new project using file system
Confusion with environment variables
after commit a folder to svn, cannot svn:ignore it?
Compilation of the java files in folders