[1.0.1] App.open() doesn't work in java code on linux

Asked by lucafaverio

Hi,
i'm using sikuli libraries in Eclipse (on a linux machine) to create a GUI test program.

I've issue with the App.open() function and, more general, with every function which uses Runtime.getRuntime().exec(cmd); under linux. They all produce the following exception:

CMD Error:java.io.IOException: Cannot run program CMD: java.io.IOException: error=2, No such file or directory

on windows, the same code worked fine.

from my tests seem that getRuntime().exec() need the absolute path to the program, so taking App.open() implementation in linux utils as example:

String cmd[] = { "sh", "-c", "(" + appName + ") &\necho -n $!" };
Process p = Runtime.getRuntime().exec(cmd);

return sh Error:java.io.IOException: Cannot run program sh: java.io.IOException: error=2, No such file or directory

instead using "/bin/sh"

String cmd[] = { "/bin/sh", "-c", "(" + appName + ") &\necho -n $!" };
Process p = Runtime.getRuntime().exec(cmd);

opens the programs as expected.

I cannot redefine every method which uses getRuntime().exec() (lots of them are in LinuxUtils class),is there a workaround to use those methods under linux?

this is my configuration:
Eclipse 3.6.2
Xubuntu 12.04
Sikuli 1.0.1

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
lucafaverio
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

/bin should normally be on system path, so no need to specify the absolute path.

check your system path settings at runtime of the script.

Revision history for this message
lucafaverio (luca-faverio) said :
#2

Thank you RaiMan i cannot check it right now, i will check it as soon aass possible.

Revision history for this message
lucafaverio (luca-faverio) said :
#3

Ok adding PATH = /bin/ in the eclipse launch configuration solve the problem, thank you!