how to call function in Java?

I have a Java program, from which I need to call a PHP-written function in a separate file- how can I do this?

  • Answer:

    A simple google search yielded this - http://stackoverflow.com/questions/614995/calling-php-from-java But IMHO, it is better to treat these services separately and provide well-defined interfaces, (say, REST like) so each side can call the other. With such interfaces, the languages used to implement the services don't matter since you can represent both success and failure cases, so the callers can take necessary actions. The services are loosely coupled, which would be a nice thing too.

Raghavendra Kidiyoor at Quora Visit the source

Was this solution helpful to you?

Other answers

If it's just one function in PHP then your best bet would be to port it to Java. The languages are fairly similar so unless it's a particularly hairy function it shouldn't be too difficult.

Paul Rothrock

The best answer is to port it.  Writing it in Java will be faster in more reliable than creating a rest interface, shelling out, etc...

Nate Lyman

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.