我正在搞乱 Runtime.getRuntime(),但我不认为这真的是我想要的。
我想要一些既有用户输入又有输出到标准输出的东西。基本上,我希望启动一个完整的单独程序。
格雷
最佳答案
这样做:
Process process = Runtime.exec( "somecommand.exeorwhatever" );
将运行一个完全独立的进程。然后你可以使用:
InputStream in = process.getInputStream();
InputStream err = process.getErrorStream();
OutputStream out= process.getOutputStream();
关于java - 如何从 java 控制台运行控制台应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15077378/