【发布时间】:2011-09-09 13:13:44
【问题描述】:
在我的 jar 应用程序中,我在 exe 程序中进行了一些计算。当 files 和 program.exe 在同一个目录中时,我使用了这个命令:
String[] str={"program.exe", "file1.txt", "file2.txt"};
pr = rt.exec(str);
而且效果很好。但是当我将文件移动到其他目录并尝试使用此命令时:
String[] str={"program.exe", "temp\\file1.txt", "temp\\file2.txt"};
pr = rt.exec(str);
program.exe 看不到文件。更奇怪的是,当我将其名称更改为默认值时,它开始看到文件。 file1.txt、file2.txt 和 temp 是在 program.exe 启动之前在我的 jar 程序中创建的。
编辑:
当问题开始时,我尝试这样:默认名称 file1.txt 和 file2.txt,我更改为 aaa.txt 和 bbb.txt(在 Windows 中),然后:
String[] str={"program.exe", "temp\\aaa.txt", "temp\\bbb.txt"};
它有效。
edit2:
现在我知道问题出在 program.exe 中。当我从命令行(而不是 jar)使用它时,像这样:
program.exe temp\file1.txt temp\file2.txt
错误:
FANN Error 1: Unable to open configuration file "temp\file1.txtÉ║@" for reading.
fann 是人工神经网络库。当我将文件复制到 program.exe 目录时:
program.exe file1.txt file2.txt
有效!当我在 temp 中更改文件名并执行以下操作时:
program.exe temp\file1aaa.txt temp\file2bbb.txt
它也有效!所以它是 fann lib 错误?
【问题讨论】:
-
这里的“本地化问题”是什么。
-
您所说的“其他任何默认设置...”是什么意思?
-
@sudmong,将其更改为“位置”,这就是我认为的意思。
-
program.exe在命令行中运行时是否看到其他目录中的文件? -
临时目录在你运行程序的目录里面吗?
标签: java file-io command-line runtime.exec