使用getrealpath方法运行.bat文件?

时间:2014-07-09 10:17:46

标签: java batch-file servlets

Greeings, 我试图使用servlet.if运行.bat文件我给静态路径执行bat文件但是当我使用getRealPath方法而不是staic路径.bat文件不执行它也不显示错误? 我的代码是:

ServletContext servletContext = request.getSession().getServletContext();
        servletContext = request.getSession().getServletContext();
        String path="/batfile.bat";
        String blastpath=servletContext.getRealPath(path);
        System.out.println(blastpath);
        Runtime run = Runtime.getRuntime();
        Process p = run.exec(blastpath);
        try {
            p.waitFor();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

0 个答案:

没有答案
相关问题