How to execute a command prompt statement using Java

S

Sharp

Hi
I would like to use Java to run the windows command prompt (a program) and
execute a particular statement (eg. cd\program\...).
Is this possible?

Any help appreciated.

Cheers
Michael

I found a solution; using Java, create a .BAT file containing the statement
to execute.
Is there a better way?

Cheers
Michael
 
K

klynn47

Runtime.getRuntime().exec(xxxx)

where xxxx is an array of commands

{"cmd.exe","/c",...}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top