public Test() throws Exception {
this.Execute("cmd.exe /c E:\\java\\workspace\\ip\\ip.bat");
} public void Execute(String cmd){
try {
java.lang.Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}
}ip.batjava -jar ip.jar如果执行 ip.jar后正常的话应该会在当前目录下创建个文本可以上面的程序运行后没有创建文件怎么回事

解决方案 »

  1.   

    我试了下 直接给路径+bat文件就行了
    public Test() throws Exception {
            this.Execute("E:\\java\\workspace\\ip\\ip.bat");
        }    public void Execute(String cmd){
            try {
                java.lang.Runtime.getRuntime().exec(cmd);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
      

  2.   


    public static void run(String command)
    {

    Runtime runtime = Runtime.getRuntime();
    try
    {
    Process process = runtime.exec("cmd /c start "+command);
    } catch (Exception ex)
    {
    ex.printStackTrace();
    }

    }