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

5
  • What's the problem? What is keeping you from implementing this? Commented Sep 15, 2014 at 6:41
  • 1
    Am I the only one who can't see the "my java program" Commented Sep 15, 2014 at 6:41
  • 1
    Set a cron to run the java program, no need to use php in this at all. Commented Sep 15, 2014 at 6:42
  • @ekostadinov we all can see the words "my java program" . But not the code Commented Sep 15, 2014 at 6:44
  • 1
    I searched for "php run java". 5,982 results. Then I searched for "run every day". 11,519 results. Please don't ask questions that have been asked and answered thousands of times before! Commented Sep 15, 2014 at 6:48

2 Answers 2

1

Run it the way you would run any command line program

var_dump(exec('java yourprogram'));
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.