Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > excute command

Reply
Thread Tools

excute command

 
 
mory2311
Guest
Posts: n/a
 
      11-04-2006
Hi all,

I'm asking about how to excute DOS command via Java code ?

can anybody guid me ?

thank you

 
Reply With Quote
 
 
 
 
Robert Mark Bram
Guest
Posts: n/a
 
      11-05-2006
Hello,

> I'm asking about how to excute DOS command via Java code ?



Start with this:
Runtime.getRuntime().exec("/path/to/batchFile.bat");

The thing you are executing must always resolve to the path of some
file you are going to run.

http://java.sun.com/j2se/1.4.2/docs/...va.lang.String)

You can use another form of exec in the same class where you send in a
string array to encapsulate arguments to the script as different array
positions. However, even the form above that accepts a String only can
also include space separated arguments.

Good luck,

Rob


 
Reply With Quote
 
 
 
 
franco
Guest
Posts: n/a
 
      11-05-2006
if you are using java5 process builder is very nice too. it comes in
handy when you want to work with standard input and error, etc.

http://java.sun.com/j2se/1.5.0/docs/...ssBuilder.html


// minimal invocation:
new ProcessBuilder("myCommand", "myArg").start();



On Nov 4, 7:43 pm, "Robert Mark Bram" <(E-Mail Removed)> wrote:
> Hello,
>
> > I'm asking about how to excute DOS command via Java code ?Start with this:

> Runtime.getRuntime().exec("/path/to/batchFile.bat");
>
> The thing you are executing must always resolve to the path of some
> file you are going to run.
>
> http://java.sun.com/j2se/1.4.2/docs/...me.html#exec(j...)
>
> You can use another form of exec in the same class where you send in a
> string array to encapsulate arguments to the script as different array
> positions. However, even the form above that accepts a String only can
> also include space separated arguments.
>
> Good luck,
>
> Rob
>


 
Reply With Quote
 
Jim Korman
Guest
Posts: n/a
 
      11-05-2006
On 4 Nov 2006 14:06:25 -0800, "mory2311" <(E-Mail Removed)> wrote:

>Hi all,
>
>I'm asking about how to excute DOS command via Java code ?
>
>can anybody guid me ?
>
>thank you


Take a look at Runtime.exec()

Jim
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excute a command within a thread cold.phusion@gmail.com Java 0 06-06-2007 02:41 PM
excute programme on tree view ? HAK Java 0 03-02-2006 08:02 PM
how to excute exe Yoshitha ASP .Net 4 06-28-2005 09:42 AM
How to create a excute file HS1 Java 3 11-17-2004 01:44 PM
Re: Very Good network Question For all, Excute file remotely He who doth Slump a lot Computer Support 0 06-21-2003 09:43 PM



Advertisments