Jump to content

running external executable file


bfmk

Recommended Posts

Hello all,

 

I have an offline java program that runs a few recommender-systems algorithms and would like to be able to run it on a website using PHP (the output is inserted into a mySQL database on the same server). I have started looking into how this is done by creating a simple HelloWorld java program, archiving it into a .jar file and using the system() function to run it in a PHP script. The return value is 127, and no output is echoed. I'm guessing the problem is that I don't have a java runtime environment set up on this server, but I was wondering if anyone had any other insight into the problem, or if anyone has tried running jar files using the system/exec function before??

 

Just in case I'm doing anything stupid on a code level, here is what I've written.

 

<?PHP 
$output = system('java -jar ./HelloTest.jar', $retval);
echo $output;
echo $retval;
?>

 

Any help would be greatly appreciated, thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/155978-running-external-executable-file/
Share on other sites

I'm guessing the problem is that I don't have a java runtime environment set up on this server

 

You are trying to run java on a system that does not have java.

 

Simple as that, you need the application to run it, the PHP is fine as far as I can tell.

Okay, so to resolve the issue I simply need a server that has JDK installed? No modifications to any PHP configurations are required to run jar files or anything?

 

That is kind of the point of system. To run a 3rd party application not associated to PHP. It calls on the "system" it self to run that application and return the results. Much like a command prompt in Windows or Linux. You can run an application from Command Line and get return values from it. But you need that application installed to run it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.