1

I have NFS installed for Windows 2008 but when I try to access C:/Windows/System32/mount.exe or umount.exe and execute it in Java, I get an IO Exception that the file cannot be found.

Runtime.getRuntime().exec("C:/Windows/System32/mount.exe <location> J:");

This also doesnt work if you were thinking it might:

Runtime.getRuntime().exec("cmd.exe /C call C:/Windows/System32/mount.exe <location> J:");

The file wont even register as existing through Java

if(new File("C:/Windows/System32/mount.exe").exists())
    System.exit(0);
else
    System.exit(-1);

This code will always exit -1

I have verified over and over again that the file does indeed exist and my command works. What is going on? How can I mount an NFS drive through Java for Windows?

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

I tried running CMD as Administrator too

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
BinaryShrub
  • 346
  • 1
  • 3
  • 14
  • This sounds like an issue with the bitness (i.e., running a 32-bit version of Java with a 64-bit version of SUA installed). `C:\Windows\System32` is redirected for 32-bit apps to `C:\Windows\SYSWOW64`. See [this question](http://stackoverflow.com/questions/1855042/system32-folder-on-a-64-bit-system) – ig0774 Apr 05 '12 at 02:06
  • @user1314180: Done. This sort of thing was in my mind as I was dealing with a similar issue not too long ago myself. – ig0774 Apr 05 '12 at 02:25

2 Answers2

2

This sounds like an issue with the bitness (i.e., running a 32-bit version of Java with a 64-bit version of SUA installed). C:\Windows\System32 is redirected for 32-bit apps to C:\Windows\SYSWOW64. See this question.

Community
  • 1
  • 1
ig0774
  • 39,669
  • 3
  • 55
  • 57
0

try create a .bat file that execute "java yourClass" and run as administrator. May be permission settings in windows.