Menu

[r608]: / branches / Release-4-3-3 / php-java-bridge / INSTALL.J2EE  Maximize  Restore  History

Download this file

116 lines (77 with data), 3.8 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. Type java -jar
  JavaBridge.jar --help to see the list of available options.

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

    // call Java libraries using the provided Java class...
    java_require("myLibs/myLib.jar;dependentLib1.jar;...);

    $SystemClazz =     Java("java.lang.System"); 
    echo $SystemClazz->getProperties();

    $myInstance  = NEW Java("myPackage.MyClass", ...); 
    $myInstance->callSomething(...);
   ?>

* Create a PHP web archive for distribution, for example with the commands:

  mkdir JavaBridge
  cd JavaBridge
  jar xvf ../JavaBridge.war

  cd ../myPhpApp
  cp -r ../JavaBridge/WEB-INF JavaBridge/java .
  cp -r MYLIBS/*.jar WEB-INF/lib
  jar cvf ../myPhpApp.war *
  

Deployment
----------

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

* Copy your web application myPhpApp.war to the autodeploy folder of
  your J2EE server or servlet engine. The following examples assume that
  you don't have a myPhpApp.war yet, they use the "JavaBridge.war" example
  application. 

  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, copy the directory which contains the web
  application "myPhpApp" over to the Apache/IIS document root or to
  the some local directory accessible by the PHP command line executable.

* Edit DOCUMENT_ROOT/myPhpApp/java/Java.inc so that it
  connects PHP with the Java VM "127.0.0.1:8080/myPhpApp". For example:

    define("JAVA_HOSTS", "127.0.0.1:8080"); 
    define("JAVA_SERVLET", "User"); 

* 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.

Logging
-------

* Download and copy log4j.jar to java.ext.dirs. Example for JDK 1.6 on
  Linux:

  mkdir -p /usr/java/packages/lib/ext
  cp log4j.jar /usr/java/packages/lib/ext

* Start the log4j viewer. For example with the command:

  /usr/java/default/bin/java org.apache.log4j.chainsaw.Main

* Restart the J2EE server. The log appears in the log4j window.


* Please report bugs/problems to the mailing list:

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


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.