import javax.swing.*;
import java.io.*;
public class EditorTest extends JFrame
{
public static void main(String[] args)
{
String strCommand = "dir .";
String cmd = "cmd";
if (!System.getProperty("os.name".equals("Windows NT")
cmd = "command";
cmd = cmd + " /c " + strCommand;
try {
System.out.println(System.getProperty("os.name");
System.out.println(cmd);
Runtime.getRuntime().exec(cmd);
}catch (IOException ex) {
System.out.println(ex);
}
//System.out.println(System.getProperties().toString());
}
}
为什么我这里运行时会有错误呢?? |
|