簡體   English   中英

Runtime.getRuntime.exec()不起作用

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

嗨,我遇到了Runtime.getruntime.exec(String cmd)的問題,實際上早些時候還可以,但是我們安裝了一些不同版本的Tomcat 6,因此在服務器上不起作用。 當我嘗試從本地調試它時,它也正在執行,但是沒有發生文件從一台服務器到另一台服務器的移動。它也沒有給出錯誤.Runtime類與Tomcat版本是否存在任何依賴關系。 這是代碼:

字符串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(String cmd)因此,它不是getruntime,而是CamelCase中的getRuntime。

您可以像這樣使用運行時:-

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

或者,為獲得更好的答案,請共享您的代碼或明確定義問題所在。

謝謝!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM