bfmk Posted April 28, 2009 Share Posted April 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/155978-running-external-executable-file/ Share on other sites More sharing options...
premiso Posted April 28, 2009 Share Posted April 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/155978-running-external-executable-file/#findComment-821076 Share on other sites More sharing options...
bfmk Posted April 28, 2009 Author Share Posted April 28, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/155978-running-external-executable-file/#findComment-821086 Share on other sites More sharing options...
premiso Posted April 28, 2009 Share Posted April 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/155978-running-external-executable-file/#findComment-821091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.