When System.exec fails (for example as a result of the incorrect executable name), it throws IOException. On Windows this exception typically looks something like the following:
java.io.IOException: CreateProcess: "C:\NOTEPAD.EXE.lnk" error=193
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
As you see, the error message is rather cryptic. The problem would be easier to diagnose if the error message for this error code is also in the message.
On Windows, one can easily obtain a human readable message for an error code by using FormatMessage API exposed from kernel32.dll. I see no reason why the the JDK cannot do this.
###@###.### 2004-11-08 23:30:33 GMT
java.io.IOException: CreateProcess: "C:\NOTEPAD.EXE.lnk" error=193
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
As you see, the error message is rather cryptic. The problem would be easier to diagnose if the error message for this error code is also in the message.
On Windows, one can easily obtain a human readable message for an error code by using FormatMessage API exposed from kernel32.dll. I see no reason why the the JDK cannot do this.
###@###.### 2004-11-08 23:30:33 GMT
- relates to
-
JDK-6410605 (process) Vista: Runtime.exec does not prompt when programs need elevated privileges
- Closed
-
JDK-5023243 (process) Error msg on exception is not displayed correctly in Japanese on XP
- Resolved