Calling java from PHP exec

Solution 1:

Turns out it was a bug specific to the PHP stack MAMP (http://www.mamp.info/).

Turns out any invocation of the JVM following fails under MAMP, e.g.:

exec('java -version');

The fix is to prefix the command with

export DYLD_LIBRARY_PATH="";

Also I realized there's no reason to use that method of invoking mxmlc.

So here's the final, working command:

exec('export DYLD_LIBRARY_PATH=""; mxmlc MyAS3App.as -default-size 360 280 -output MyAS3App.swf');

Solution 2:

I manage to get this to work togheter with MAMP. The solution was to include the:

export DYLD_LIBRARY_PATH="";
in the exec call:

$argss = "export DYLD_LIBRARY_PATH=\"\"; /usr/bin/java -jar /Applications/yourjarfile.jar";
$resultXML = exec($argss, $output);

Solution 3:

Is there a reason why your using the mxmlc jar file to compile your flex application? have you tried using the executable or an ant task, instead?

Maybe the compiling is taking too long so that your PHP script times out?