MrBob
MrBob

Reputation: 33

php exec on java jar file output is empty array

I got a new mac and installed the same xampp web server as my old one. Everything has been fine except when I call a java file :

$str_exec = "java  -jar HelloWorld.jar";
exec($str_exec, $output,$result);

$output is now an empty array(), and $result = 5

I've tried absolute paths, permissions on everything, changing the user and group in https.conf (none of which I had to do before!)

I swear nothing has changed except I'm now using a macbook pro instead of an air. The files have always matched our main server files. The only thing appearing in the error log is:

dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /Applications/XAMPP/xamppfiles/lib/libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO

Help please!! I've gone through all the similar threads to this issue on here and can't find anything on the internet anywhere! Gnh

Upvotes: 3

Views: 960

Answers (1)

Ken
Ken

Reputation: 672

EDIT:
Don't use the solution below. It will eventually break, as expected. Mine finally broke, throwing dyld errors when I tried to start the apache server. It wouldn't start at all. No idea why it worked before and doesn't now, but it doesn't matter. Just ditch XAMPP, and follow these instructions to spin up your own stack: http://jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/

Good luck!

ORIGINAL ANSWER:
Ok, I've got a working solution, although I know that it's not the safest by a long shot.

Here's what's up: DYLD_LIBRARY_PATH is a var that modifies the way that the dynamic linking library looks for libs. Apparently many developers think that your software should not use this var. XAMPP does.

According to one solution, you can simply edit out the lines that include this file. (http://www.pdflib.com/fileadmin/pdflib/pdf/support/PDFlib-in-PHP-HowTo.pdf). Open xamppfiles/bin/envvars with an editor and remove the lines that set and export DYLD_LIBRARY_PATH. Then restart apache.

However, this did not work for me. I also tried the same in a file called xamppfiles/bin/envvars-std. Still didn't work. It may be worth a try though.

The problem is that the XAMPP library conflicts with the mac osx library. So I just (effectively) deleted the XAMPP library. Of course that broke another library, but I continued on deleting the (hopefully redundant) XAMPP libs until it worked. Here's what I had to do:

XAMPP/xamppfiles/lib% sudo mv libjpeg.dylib _changed_libjpeg.dylib XAMPP/xamppfiles/lib% sudo mv libtiff.dylib _changed_libtiff.dylib XAMPP/xamppfiles/lib% sudo mv libpng.dylib _changed_libpng.dylib XAMPP/xamppfiles/lib% sudo mv libiconv.2.dylib _changed_libiconv.2.dylib XAMPP/xamppfiles/lib% sudo mv libexslt.0.dylib _changed_libexslt.0.dylib XAMPP/xamppfiles/lib% sudo mv libxml2.2.dylib _changed_libxml2.2.dylib XAMPP/xamppfiles/lib% sudo mv libxslt.1.dylib _changed_libxslt.1.dylib

After I moved each library to a name where it couldn't find it, I reran the script. It would error on another lib, and I would move it. After a few of these, it stopped. Everything still seems to be working fine in my XAMPP and Apache deployments.

And more importantly, I can now run exec("/usr/bin/php -v"); successfully!

HTH

Upvotes: 3

Related Questions