我正在尝试制作一个Java脚本,用户可以在其中从Eclipse中的Java控制台键入命令,并且该命令将被发送到cmd。例如,当你运行程序时,控制台会询问用户要使用什么命令,他们输入的命令将被发送到cmd。
最佳答案
Console console = System.console();
String com = console.readLine("Enter command:");
Process child = Runtime.getRuntime().exec(com);
关于java - 使用Java向cmd输入命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24478420/