我爲Windows 2008安裝了NFS,但是當我嘗試訪問C:/Windows/System32/mount.exe或umount.exe並在Java中執行它時,我得到一個IO異常,該文件無法找到。Runtime.getRuntime()。exec()問題與Java NFS中的NFS
Runtime.getRuntime().exec("C:/Windows/System32/mount.exe <location> J:");
這也行不通的,如果你想這可能:
Runtime.getRuntime().exec("cmd.exe /C call C:/Windows/System32/mount.exe <location> J:");
文件甚至不會註冊爲通過Java
if(new File("C:/Windows/System32/mount.exe").exists())
System.exit(0);
else
System.exit(-1);
現有的規範將永遠退出-1
我已經一遍又一遍地驗證文件確實存在,我的命令起作用。到底是怎麼回事?如何通過Java for Windows安裝NFS驅動器?
java.io.IOException: Cannot run program "C:/Windows/System32/mount.exe": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at Data.SystemExecutor.exec(SystemExecutor.java:46)
at Data.SystemExecutor.exec(SystemExecutor.java:18)
at Mount.Mount.setMount(Mount.java:40)
at Mount.Mount.<init>(Mount.java:30)
at Main.Main.main(Main.java:94)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
我試圖運行CMD以管理員身份太
請發佈堆棧跟蹤。 – 2012-04-05 01:51:11
這聽起來像是位的問題(即,運行安裝了64位版本SUA的Java的32位版本)。 'C:\ Windows \ System32'將32位應用程序重定向到'C:\ Windows \ SYSWOW64'。看到[這個問題](http://stackoverflow.com/questions/1855042/system32-folder-on-a-64-bit-system) – ig0774 2012-04-05 02:06:20
@ user1314180:完成。這種事情在我腦海裏,因爲我自己也在不久前處理過類似的問題。 – ig0774 2012-04-05 02:25:06