从java代码调用可执行文件
我试图用java代码中的参数运行一个可执行文件。在控制台中,当我希望运行我的exe时,我会写:从java代码调用可执行文件,java,exe,Java,Exe,我试图用java代码中的参数运行一个可执行文件。在控制台中,当我希望运行我的exe时,我会写:>colorDescriptor 1.jpg——检测器密集采样——ds_间距6——ds_比例1.2——描述符对立项SIFT——码本码本——输出输出。descr。当我试图从java运行该可执行文件时,我使用了以下代码: String[] cmd = { "colorDescriptor.exe" , "1.jpg", " --detector densesampling --ds_spacing
>colorDescriptor 1.jpg——检测器密集采样——ds_间距6——ds_比例1.2——描述符对立项SIFT——码本码本——输出输出。descr
。当我试图从java运行该可执行文件时,我使用了以下代码:
String[] cmd = { "colorDescriptor.exe" , "1.jpg", " --detector densesampling --ds_spacing 6 --ds_scales 1.2 --descriptor opponentsift --codebook CODEBOOK ", " --output output.descr"};
Process process = Runtime.getRuntime().exec(cmd);
waitF(process);
但是它似乎无法正常工作,我遇到了以下问题:
警告:没有要写入的输出文件。您是否忘记指定--output?
调用.exe时是否有错误?在字符串[]cmd中,每个参数都应该是一个单独的字符串;
e、 g:
您必须以单个字符串或包含多个字符串的字符串数组的形式提供命令,然后在try-catch块中换行,因为exec(…)抛出异常
Throws:
SecurityException - If a security manager exists and its checkExec method doesn't allow creation of the subprocess
IOException - If an I/O error occurs
NullPointerException - If command is null
IllegalArgumentException - If command is empty
使用ProcessBuilder。处理流。
Throws:
SecurityException - If a security manager exists and its checkExec method doesn't allow creation of the subprocess
IOException - If an I/O error occurs
NullPointerException - If command is null
IllegalArgumentException - If command is empty