[英]Java visible command line
I just tried to execute a java command using runtime like this: 我只是试图使用运行时执行一个Java命令,如下所示:
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. 关闭计算机,但是我正在接受一个项目的培训,该项目将同时提高我的电子和计算机技能,因此我想执行avrdude命令以从Java编写MCU并编写GUI程序。 So I want the cmd window to be visible when I run the command.
因此,我希望在运行命令时cmd窗口可见。 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 谢谢大家
Following would do it for you. 以下将为您做到。
CMD.EXE /K your_command CMD.EXE / K您的命令
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:
制作.bat文件并使用java File类运行它会怎样,但是仍然在制作bat文件并尝试运行时仍然多次获得该命令,如下所示:
http://i.imgur.com/cMddMh5.png http://i.imgur.com/cMddMh5.png
but all I did was only write avrdude in the bat file: 但是我所做的只是在bat文件中写avrdude:
http://i.imgur.com/PDbi2vJ.png http://i.imgur.com/PDbi2vJ.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..!! 我只是在互联网上查找它,然后想出了一个解决方案,该方案正在制作.cmd文件而不是.bat文件,并且在不循环播放的情况下非常有效,感谢所有答复者。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.