try
{
String command = "dir";
Process child = 
Runtime.getRuntime().exec(command);
}
catch(IOException e)
{
}

解决方案 »

  1.   

    Win2000(Server) + JDK1.3
    --
    java.io.IOException: CreateProcess: dir error=2
            at java.lang.Win32Process.create(Native Method)
            at java.lang.Win32Process.<init>(Unknown Source)
            at java.lang.Runtime.execInternal(Native Method)
            at java.lang.Runtime.exec(Unknown Source)
            at java.lang.Runtime.exec(Unknown Source)
            at java.lang.Runtime.exec(Unknown Source)
            at java.lang.Runtime.exec(Unknown Source)
            at runcmd.main(runcmd.java:11)
    --
    55555555555 ... 
      

  2.   

    exec的参数必须是一个可执行的程序, 换一个Exe即可, 如:
    import java.lang.*;
    import java.io.*;public class process {
    public static void main(String args[]){
    try
    {
    String command = "c:\\temp\\1.exe";
    Process child = Runtime.getRuntime().exec(command);
    }
    catch(IOException e)
    {
    e.printStackTrace();
    System.out.println("exe");
    }
    }
    }