简体   繁体   中英

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. 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. This is the code:

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

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.

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!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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