Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望能够与我的 Java 代码同时运行外部 cmd 提示符。运行 java 应用程序时需要启动外部 cmd 提示符,并且这个命令提示符需要从我的 java 应用程序更新,我需要从这个命令提示符获取值到 java 应用程序。请提供合适的建议
尝试这个
Runtime rt = Runtime.getRuntime(); rt.exec("cmd.exe /c start command");
更新 2
要执行命令试试这个
rt.exec("cmd.exe /c start cmd.exe /k \"ping localhost\"");