I am trying to run an executable with its argument from java code. In console when I wish to run my exe I write: >colorDescriptor 1.jpg --detector densesampling --ds_spacing 6 --ds_scales 1.2 --descriptor opponentsift --codebook CODEBOOK --output output.descr
. When I tried to run that executable from java I am using the following code:
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);
However it seems not to work properly, I got the following issue: Warning: no output file to write to. Did you forget to specify --output?
Warning: no output file to write to. Did you forget to specify --output?
Am I doing something wrongly when I call .exe?
Every argument should be a separate String in String[] cmd; eg:
String[] cmd = { "colorDescriptor.exe" , "1.jpg", "--detector", "densesampling", "--ds_spacing", "6", "--ds_scales", "1.2", "--descriptor", "opponentsift", "--codebook", "CODEBOOK", "--output", "output.descr"};
You have to provide command either as single string or string array containing several strings and then Wrap within try-catch block, as exec(...) throws exception
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.