简体   繁体   English

从PHP5调用Java方法

[英]Call Java method from PHP5

There used to be a PHP extension that could load Java libraries and call methods in them. 曾经有一个PHP扩展可以加载Java库并调用其中的方法。 That was for PHP 4. 那是PHP 4。

Is there a way to do the same in PHP 5? 有没有办法在PHP 5中做同样的事情?

If you need Java integration in PHP 5, there is the Zend Server Java bridge: 如果你需要PHP 5中的Java集成,那就是Zend Server Java桥:

http://www.zend.com/en/products/server-ce/ http://www.zend.com/en/products/server-ce/

and "PHP/Java Bridge": 和“PHP / Java Bridge”:

http://php-java-bridge.sourceforge.net/pjb/ http://php-java-bridge.sourceforge.net/pjb/

EDIT 编辑

If you don't like either of the above options, then consider using Quercus . 如果您不喜欢上述任一选项,请考虑使用Quercus This is a Java implementation of PHP, that makes it easy to reference Java from within PHP and vice-versa 这是PHP的Java实现,可以很容易地从PHP中引用Java,反之亦然

Doesn't look like there's a built-in way, even the support in php4 was experimental. 看起来不像是内置的方式,即使php4中的支持也是实验性的。 Doesn't really make sense to start up a Java Virtual Machine on each request for php. 在每个php请求上启动Java虚拟机真的没有意义。 You could always use the shell-escaping capabilities (backtick operator) if you have to do something in Java but if you want to make something scalable it needs to be its own Java service and accept SOAP/REST or however you want to talk to it from php. 你总是可以使用shell转义功能(反引号操作符),如果你必须在Java中做一些事情,但如果你想做一些可扩展的东西,它需要是自己的Java服务并接受SOAP / REST,或者你想要与之交谈来自php。

You could use Quercus. 你可以使用Quercus。 It's a PHP 5 runtime written in Java you can install on top of a JavaEE application server. 它是用Java编写的PHP 5运行时,可以安装在JavaEE应用程序服务器之上。

http://www.caucho.com/products/quercus/ http://www.caucho.com/products/quercus/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM