我为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