java.lang.Runtime.exec fails on Mac

Joined
Mar 26, 2009
Messages
1
Reaction score
0
Points
1
Hi folks;
I am developing a java program that needs to run commands as if it were from command line. I have a binary in /Applications/LabPrints/Image Aligner/LabPrints.dalp
and when I run it from command line, it runs but when I try to run it form Java with
Code:
String cmd="\"/Applications/LabPrints/Image Aligner/LabPrints.dalp\"";
Runtime.exec(new String[]{cmd});
I get an error with the output:

java.io.IOException: "/Applications/LabPrints/Image Aligner/LabPrints.dalp": not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:54)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:491)
at java.lang.Runtime.exec(Runtime.java:457)
at krs.MainClass.main(MainClass.java:28)

Does anyone has any idea what I am missing? I am running the same on PC and it runs perfectly. I am also capturing the output and error streams of the created process in separate threads.

Thanks in advance...
Kamal
 
Joined
Mar 28, 2009
Messages
2
Reaction score
0
Points
1
Try sending the command without the escaped quotes. The quotes are just to help the terminal identify the application path as a single argument. But when you send it with the quotes through the exec() method, it thinks the quotes are part of the filename.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top