I want to run a C++ program from Java in Linux
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("/home/user/myProgram inputFilePath secondArgument");
int exitVal = pr.waitFor();
If I run the same command from a terminal everything works fine, the problem is when I run it from Java. I am getting exit code 139. The program gets executed but something fails while executing. Actually if I do not enter the inputFilepath
the program is executed just fine and I can catch the message over the stdout about the "missing input file".
Any idea?
SOLUTION: After some trial and error I found the problem. Apparently a "\n" was needed at the end of the parameters, probably used as flag by the C++ program I was running. There was for sure a segmentation fault while parsing the arguments.