Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.