I am writing a Java class. And I have some logic in test.php.
One of the methods of that Java class should invoke test.php,
so that test.php performs some computation and returns the result to the invoking Java method. Can I do that with something like the following?
Runtime rt = runtime.getRuntime();
process exec = rt.exec(test.php);
解决方案
You should use the JSR-223 scripting API. There is a PHP implementation that uses a Java/PHP bridge:
I have not used this myself. But Caucho's Quercus product uses it, so I would suspect it is mature enough to do whatever you need.
Here are some other links that may help you: