简体   繁体   English

Runtime.getRuntime.exec()不起作用

[英]Runtime.getruntime.exec() not working

Hi I am facing issue with Runtime.getruntime.exec(String cmd) actually earlier this was working fine but we installed some different version of Tomcat 6 so it is not working on server. 嗨,我遇到了Runtime.getruntime.exec(String cmd)的问题,实际上早些时候还可以,但是我们安装了一些不同版本的Tomcat 6,因此在服务器上不起作用。 When I am trying to debug it from locally then also it is executing but movement of file from one server to another is not happening.It is not giving error also.Is there any dependency of Runtime class with Tomcat version. 当我尝试从本地调试它时,它也正在执行,但是没有发生文件从一台服务器到另一台服务器的移动。它也没有给出错误.Runtime类与Tomcat版本是否存在任何依赖关系。 This is the code: 这是代码:

String cmd1 = "cmd.exe /c move \\\\Server123\\d$\\excel\\Products\\html\\" + u_user + datevalue + ".html" + " D:\\excel\\Products\\html\\"; 字符串cmd1 =“ cmd.exe / c move \\\\ Server123 \\ d $ \\ excel \\ Products \\ html \\” + u_user + datevalue +“ .html” +“ D:\\ excel \\ Products \\ html \\”;

Runtime.getruntime.exec(cmd1); Runtime.getruntime.exec(cmd1);

It is not giving any error. 它没有给出任何错误。

If you are trying to get Runtime object as you write in your question via:- 如果您尝试通过以下方式写问题时获取运行时对象:

Runtime.getruntime.exec(String cmd) So its not getruntime its getRuntime in CamelCase. Runtime.getruntime.exec(String cmd)因此,它不是getruntime,而是CamelCase中的getRuntime。

You can use Runtime like this:- 您可以像这样使用运行时:-

Runtime runtime = Runtime.getRuntime()
    Process croppingProcess = runtime.exec(runtimeCommand)
        int processOutput = croppingProcess.waitFor()
        if(processOutput == 0){
            success = true
    //do your work here
}

Or for better answer please share your code or clearly define your question where you exactly stuck. 或者,为获得更好的答案,请共享您的代码或明确定义问题所在。

Thanks!! 谢谢!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM