Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

excute command

Thread view: 
mory2311 - 04 Nov 2006 23:06 GMT
Hi all,

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

can anybody guid me ?

thank you
Robert Mark Bram - 05 Nov 2006 01:43 GMT
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/api/java/lang/Runtime.html#exec(java.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
:)
franco - 05 Nov 2006 03:22 GMT
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/api/java/lang/ProcessBuilder.html

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

> Hello,
>
[quoted text clipped - 15 lines]
> Rob
> :)
Jim Korman - 05 Nov 2006 04:27 GMT
>Hi all,
>
[quoted text clipped - 3 lines]
>
>thank you

Take a look at Runtime.exec()

Jim


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.