0

I just tried to execute a java command using runtime like this:

Runtime.getRuntime().exec("shutdown -s");

to shutdown the computer, but I am training on a project that will get both my electronics and computer skills so I want to execute an avrdude command to program the mcu from Java and make a GUI program. So I want the cmd window to be visible when I run the command. I just made it visible by:

Runtime.getRuntime().exec("cmd.exe /c start");

but I cant write on the window I just created, any help pls????

thanks all

nobody
  • 19,814
  • 17
  • 56
  • 77
user3407319
  • 227
  • 2
  • 10
  • Google stream redirection for Processes in java, or check out this SO post :D http://stackoverflow.com/questions/10407308/redirect-stdin-and-stdout-in-java – Mark W Apr 02 '14 at 21:25

2 Answers2

0

Following would do it for you.

CMD.EXE /K your_command

J.J
  • 633
  • 1
  • 6
  • 14
0

I got an idea but still need some help! What about making a .bat file and running it using java File class but still when I make a bat file and try to run I get the command multiple times like this:

https://i.stack.imgur.com/N4tmZ.png

but all I did was only write avrdude in the bat file:

https://i.stack.imgur.com/YVjb4.png

still need help in that!!

thanks for all answers...


EDIT::


I just looked it up in the internet and figured out a solution which is making a .cmd file instead of a .bat file and that worked great without looping thanks for all the repliers..!! :)

user3407319
  • 227
  • 2
  • 10