先得到Runtime rt=Runtime.getRuntimee()对象.]
然后应用rt中的exec方法.
如rt.exec(String cmd);
cmd:完整的命令行.如:aaa.exe -ccc
public Process exec(String[] cmdarray,
                    String[] envp)
             throws IOException
Executes the specified command and arguments in a separate process with the specified environment. 
Given an array of strings cmdarray, representing the tokens of a command line, and an array of strings envp, representing "environment" variable settings, this method creates a new process in which to execute the specified command. If envp is null, the subprocess inherits the environment settings of the current process. 
Parameters:
cmdarray - array containing the command to call and its arguments.
envp - array of strings, each element of which has environment variable settings in format name=value. 
Returns:
a Process object for managing the subprocess. 
Throws: 
SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. 
NullPointerException - if cmdarray is null. 
IndexOutOfBoundsException - if cmdarray is an empty array (has length 0). 
IOException - if an I/O error occurs
See Also:
Process, SecurityException, SecurityManager.checkExec(java.lang.String)--------------------------------------------------------------------------------
记得要给分啊.呵呵

解决方案 »

  1.   

    补充,如果exec成功.
    得到一个Process对象,代表你执行的程序.
    用这个对象的getInputStream()方法,取得输入流,就可以读到返回值了.
    其他请参看API文档.
      

  2.   

    有关的java帮助我也看到了,我需要的是实例。
    比如说调用notepad,ping 127.0.0.1 的到返回值
    不过我还会给你分的。等一会有更好的方法时。
    再问,是不是调用的程序,必须由,java来结束?
      

  3.   

    例子:
    Runtime rt=Runtime.getRuntimee();
    rt.exec("C:\\Program Files\\Accessories\\Wordpad D:\\xxxx.txt");
      

  4.   

    调用的程序属新建进程,即使你关闭java程序,它还是正常运行。