I have a Java program with a healthy Java API, but I want to build a primitive interface between my java application and php script, as these are the requirements of my project.
My first attempt was to write a PHP script in which the passthru function was run to run the jar. i.e.
passthru("java -jar myjarfile param1 param2 param3")
This worked, but turned out to be rather slow, because the jar file had to be launched and executed, etc.
My next attempt was to create a servlet on Tomcat7 and link it to PHP using the curl () command. i.e.
curl(http:
This had excellent performance, but the servlet was very unstable and crashed after about 5 minutes (I loaded the server with about 1 request every 10 seconds)
I come to Stack Overflow asking: am I doing this right? Is there a better way? How can I run my java program in jvm and interact with it using PHP?
thank
source
share