Php/Java Integration

前端 未结 5 471
挽巷
挽巷 2020-12-11 21:13

Have you experience of integration of php and Java? I\'ve written a class in Java \"Hello\". Now I want to call its method from php when I create an instance of this class f

相关标签:
5条回答
  • 2020-12-11 21:27

    There are many ways few are:

    • PHP Java Bridge
    • Java Integration in PHP
    • Using web services to pass data in between like SOAP
    • Using simple HTTP data passage between Java and PHP see (facejar uses the same technique)

    • Client site script (AJAX)

    If you are after security, use option 1 otherwise I prefer using option 4 which is a bit faster when it comes to performance.

    0 讨论(0)
  • 2020-12-11 21:46

    Could it be you are just missing the quotes around the Java Class? Also make sure you actually do have a Java VM on the machine you are trying to run the code on and make sure you have properly set up the config options. Also, the Java extension is a PECL extension and has to be installed. It is not part of the native distribution. Furthermore, the extension is considered unmaintained and dead, so you might want to have a look at the JavaBridge suggested elsewhere. Zend Server also brings a JavaBridge.

    0 讨论(0)
  • 2020-12-11 21:50

    In my experience the best way to interact between Java and PHP is through a WebService layer. NuSoap for PHP is very good, and you can consume the webservice in Java to create a stub that will build the request/response object.

    0 讨论(0)
  • 2020-12-11 21:52

    Have a look at:

    PHP-Java Bridge

    The PHP/Java Bridge is an implementation of a streaming, XML-based network protocol, which can be used to connect a native script engine, for example PHP, Scheme or Python, with a Java virtual machine. It is up to 50 times faster than local RPC via SOAP, requires less resources on the web-server side. It is faster and more reliable than direct communication via the Java Native Interface, and it requires no additional components to invoke Java procedures from PHP or PHP procedures from Java.

    0 讨论(0)
  • 2020-12-11 21:52

    Check out this article: http://www.devshed.com/c/a/PHP/Using-PHP-with-Java/

    They say it's possible (and how to do it). I've never done it, so I can't vouch for it...

    0 讨论(0)
提交回复
热议问题