Java、本机应用程序和全局路径
我需要执行一个批处理文件(在 Java 6 中)并为此使用以下代码:
final String command = "C:\Ruby191\bin\mygem.bat inputfile.dat";
final File parent = new File(aParentDir);
Process proc;
proc = aRuntime.exec(command, null, parent);
但我得到这个异常:
...Exception: java.io.IOException: Cannot run program "
C:\Ruby191\bin\mygem.bat" (in directory "src\test\resources\...
"): CreateProcess error=267, Directory name invalid
有问题的批处理文件存在于指定的目录中。
我的代码有什么问题?
I need to execute a batch file (in Java 6) and use following code for this:
final String command = "C:\Ruby191\bin\mygem.bat inputfile.dat";
final File parent = new File(aParentDir);
Process proc;
proc = aRuntime.exec(command, null, parent);
But I get this exception:
...Exception: java.io.IOException: Cannot run program "
C:\Ruby191\bin\mygem.bat" (in directory "src\test\resources\...
"): CreateProcess error=267, Directory name invalid
The batch file in question exists in the specified directory.
What is wrong in my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用双反斜杠
\\
或单斜杠/
而不是单反斜杠。还要检查当前目录名称。Try using double backslashes
\\
or single slashes/
instead of single backslashes. Check current directory name too.