File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14266
    
  21

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
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
 
Consider Paul's rocket mass heater.
 
subject: Executing System level commands