Menu

[r681]: / branches / jostb-debian-ubuntu-patch / php-java-bridge / INSTALL.J2EE  Maximize  Restore  History

Download this file

91 lines (63 with data), 3.2 kB

Overview
--------

This document describes how to call Java methods from PHP. And how to
embed PHP applications into a pure Java application server or servlet
engine. Please see the INSTALL.J2SE document for details how to call
PHP methods from a pure Java application.

The PHP/Java Bridge can be installed with one copy operation:

* the JavaBridge.war must be copied into the autodeploy folder of the
  J2EE server.


Development
-----------

* Extract the JavaBridge.jar from the JavaBridge.war zip file from the
  PHP/Java Bridge binary download. Double-click on JavaBridge.jar or
  type "java -jar JavaBridge.jar" and click "OK" to start a servlet
  engine back end for all computers on the local network.

* Link Java.inc and your Java libraries into PHP at run-time. Example:
  
   <?php
    require_once("http://localhost:8080/JavaBridge/java/Java.inc");

    // call Java libraries using the provided Java class...
    java_require("myLibs/myLib.jar;dependentLib1.jar;...);
    $my = new Java("myPackage.MyClass", ...);
    $my->callSomething(...);
   ?>


Deployment
----------

* Install a J2EE application server or servlet engine, for example
  Apache Geronimo, Tomcat, Glassfish, ...

* Extract the files from the php-java-bridge J2EE download and deploy
  JavaBridge.war into your J2EE server, example for Tomcat on Unix: 
  
    cp JavaBridge.war $CATALINA_HOME/webapps/

  Example for Apache Geronimo on Windows:

    copy JavaBridge.war "\Program Files\IBM\WebSphereCommunityEdition\deploy"

* If you want to run PHP as a sub component of the J2EE server or
  servlet engine, visit http://localhost:8080/JavaBridge and click on
  test.php. 

* If you want to run PHP as a sub component of Apache or IIS or from
  the command line, create a simple test.php file and call it as usual.
  For example:

  <?php
    require_once("http://localhost:8080/JavaBridge/java/Java.inc");
    $s = new Java("java.lang.System");
    echo $s->getProperties();
  ?>

  copy it to the web server document root and browse to
  http://yourHost.com/test.php or use the PHP command line
  interface. For example:

    php-cgi test.php >result.html

* Firewall-out the J2EE/Servlet port 8080, if necessary. Or modify the
  J2EE/Servlet so that it listens only on the local interface. Note that
  in the default setup the PHP/Java Bridge rejects requests from non-local
  PHP clients. For a intranet server start the J2EE/Servlet VM with the
  parameter -Dphp.java.bridge.promiscuous=true or set the "promiscuous"
  init-param in the J2EE WEB-INF/web.xml and make sure that your
  computer cannot be accessed from the internet. At least firewall-out
  the ports 8080 and all ports in the range [9267,...,[9367 and read the
  "security" sections from README.

* Please report bugs/problems to the mailing list:

    php-java-bridge-users@lists.sourceforge.net


* An optimized implementation, which is up to 10 times faster than the
  pure PHP implementation described above, is available as C source. 
  Please see the README and INSTALL document located in the source
  download archive how to compile an optimized "php_java.dll" or
  "java.so" for your operating system.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.