How to open the command prompt and insert commands using Java?
Posted
by
404 Not Found
on Stack Overflow
See other posts from Stack Overflow
or by 404 Not Found
Published on 2011-01-14T05:00:55Z
Indexed on
2011/01/14
5:53 UTC
Read the original article
Hit count: 193
There have been a few other questions on here sort of like this, but none seem to have any answers.
Is it possible to open the command prompt (and I guess any other terminal for other systems), and execute commands in the newly opened window?
Currently what I have is this:
Runtime rt = Runtime.getRuntime();
rt.exec(new String[]{"cmd.exe","/c","start"});
I've tried adding the next command after the "start", I've tried running another rt.exec containing my command, but I can't find a way to make it work.
If it matters, I'm trying to run a command similar to this:
java -flag -flag -cp terminal-based-program.jar
© Stack Overflow or respective owner