Runtime.getRuntime().exec() issue with Windows NFS in Java

Go To StackoverFlow.com

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

2012-04-05 01:48
by BinaryShrub
Post the stack trace please - Jim Garrison 2012-04-05 01:51
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 questionig0774 2012-04-05 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 2012-04-05 02:25


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.

2012-04-05 02:24
by ig0774
Thanks for your help. I will always remember this now - BinaryShrub 2012-04-05 02:32
I would vote up byt I dont have the rep yet - BinaryShrub 2012-04-05 02:33


0

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

2012-04-05 02:01
by pancatrevisan
I tried running CMD as administrato - BinaryShrub 2012-04-05 02:05
Ads