I am trying to run a c++ executable from my Java web application. When I go the relevant page it executes the commands and runs the executable but does not produce any output.
Here is my code:
URL createWav = QRcodeController.class.getClassLoader().getResource("createWav");
log.info("The path of the c++ executable obtained: "+ createWav.getPath());
Process p1 = Runtime.getRuntime().exec("chmod 777 " + createWav.getPath());
p1.waitFor();
int exitVal=1;
try {
Process p2 = Runtime.getRuntime().exec(createWav.getPath(), args);
exitVal = p2.waitFor();
}
catch (Exception e)
{
log.error(e.getStackTrace());
}
if(exitVal == 1)
throw new Exception("Error in c++ program");
It does not throw any error so the c++ program runs fine but it does not produce the file it is supposed to. When I run the same command from the command line in the same machine it works perfectly producing the required file. I am not sure what I am doing wrong.