package Test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.swing.JOptionPane; public class CmdTest ... { public static void main(String[] args) throws IOException ...{ String cmdStr = JOptionPane.showInputDialog("输入命令"); Runtime rt = Runtime.getRuntime(); Process process = rt.exec(cmdStr, null); String output; InputStream pin = process.getInputStream(); InputStreamReader cin = new InputStreamReader(pin); BufferedReader in = new BufferedReader(cin); try ...{ output = in.readLine(); while (output != null) ...{ System.out.println(output); output = in.readLine(); } in.close(); } catch (IOException e) ...{ System.out.println("出错了~~"); e.printStackTrace(); } }} 把cmdStr换成 "d:/muma.exe"就是调用d盘的muma.exe程序 这个好玩。