Which one is the best way to call a PHP script from JAVA? I'm calling now the PHP executable using the next code:
CommandLine command = new CommandLine("php");
command.addArgument("file.php");
DefaultExecutor exec = new DefaultExecutor();
PumpStreamHandler streamHandler = new PumpStreamHandler(null, null);
exec.setStreamHandler(streamHandler);
int execute = exec.execute(command);
But loading and disposing the php executable consumes resources. What about Java SAPI or something like loading a php module into java?
I'm calling the "exec.execute(command);" inside a loop.