-2

i have a PHP script which is provide to my one of the friend he is java developer. that script is on class which is in java language.

i need to run that java program to complete my task. i need to run sum action once in day, and perform sum logical action and updated my data in database everyday. Please let me know i to do it in php.

here is my java program code.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • What's the problem? What is keeping you from implementing this? – Emil Lundberg Sep 15 '14 at 06:41
  • 1
    Am I the only one who can't see the "my java program" – ekostadinov Sep 15 '14 at 06:41
  • 1
    Set a cron to run the java program, no need to use php in this at all. – Jite Sep 15 '14 at 06:42
  • @ekostadinov we all can see the words _"my java program"_ . But not the code – Baby Sep 15 '14 at 06:44
  • 1
    I searched for "[php run java](http://stackoverflow.com/search?q=php+run+java)". *5,982* results. Then I searched for "[run every day](http://stackoverflow.com/search?q=run+every+day)". *11,519* results. Please don't ask questions that have been asked and answered thousands of times before! – Sverri M. Olsen Sep 15 '14 at 06:48

2 Answers2

1

Run it the way you would run any command line program

var_dump(exec('java yourprogram'));
Isaac
  • 983
  • 1
  • 7
  • 13
0

Perhaps in my opinion the best way would be as follows:

  1. Run your java application on your server with another port (say port 1212)
  2. If it is not needed outside your web server, better restrict the apache tomcat server not to expose port 1212 to anyone outside localhost (you can achieve it with iptables on linux)
  3. Now from PHP, make CURL calls to your java application like http://localhost:1212/my_jar_code.jsp
  4. Use it like web services, problem solved!

In this way your java code will be independent of your php code and you have complete compatibility and power on both java and php codes.

DJ'
  • 1,760
  • 1
  • 13
  • 26